Django-jet: How to create custom widgets?

Created on 21 Mar 2016  路  4Comments  路  Source: geex-arts/django-jet

Hi! I need a little support. I need to add a map(getting data from my models) with time slider filters that is going to be used for monitoring and little work; and need to do a lot of customization with that map. So I thought it'll be a great idea to create a widget for the map and use it. I need to know how do I write a custom widget and include it in the admin panel. Can you please help me doing that? Or let me know if there is a better way to add that map in the admin panel?

Most helpful comment

Now there is documentation about it:

  1. Create custom dashboard http://jet.readthedocs.io/en/latest/dashboard_getting_started.html
  2. Create custom dashboard module http://jet.readthedocs.io/en/latest/dashboard_custom_module.html

All 4 comments

Well there is not much info in docs about doing this but as a start (the way it worked for me maybe there is a better way) you need to create a CustomDashboard

http://jet.readthedocs.org/en/latest/dashboard_getting_started.html#set-up-custom-dashboard

Next, you need to extend jet.dashboard.modules.DashboardModule and create your module class, see the original source for have an idea of how it works, basically you need to edit template and render method:

Example:

class ModuloUsuariosPorCarrera(modules.DashboardModule):
    template = 'admin/modulos/usuarios_por_carrera.html'
    title = 'Usuarios por carrera'

    def render(self):
        ... your custom method...

And next, add it to your custom dashboard

def init_with_context(self, context):
        ... other modules here...
        self.available_children.append(ModuloUsuariosPorCarrera)
        ...

My result:
Imgur

Now there is documentation about it:

  1. Create custom dashboard http://jet.readthedocs.io/en/latest/dashboard_getting_started.html
  2. Create custom dashboard module http://jet.readthedocs.io/en/latest/dashboard_custom_module.html

@kliver Hello, I would like to add a chart to dashboard of django-jet as you did, could you please share to me the file that you realized ? (because I am new in django, so I don't know too much, I hope you could help me)
thanks in advance

I am planning to add folium map how can I do it ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seenu4linux picture seenu4linux  路  3Comments

erayerdin picture erayerdin  路  5Comments

kevin-miles picture kevin-miles  路  5Comments

ramses132 picture ramses132  路  3Comments

annamalaissh picture annamalaissh  路  5Comments