django-jet icon indicating copy to clipboard operation
django-jet copied to clipboard

Cant load custom dashboard

Open ZeusNabartey opened this issue 7 years ago β€’ 28 comments

Hi. I cant load my custom dashboard. this is the error.

File "/home/Desktop/venv/local/lib/python2.7/site-packages/jet/dashboard/templatetags/jet_dashboard_tags.py", line 14, in get_dashboard return dashboard_cls(context, app_label=app_label) TypeError: 'NoneType' object is not callable

and this is the error in debug mode:

Error during template rendering

In template /home/Desktop/venv/local/lib/python2.7/site-packages/jet/dashboard/templates/admin/index.html, error at line 4 'NoneType' object is not callable 1 {% extends "admin/base_site.html" %} 2 {% load i18n admin_static jet_dashboard_tags static %} 3 4 {% block html %}{% get_dashboard 'index' as dashboard %}{{ block.super }}{% endblock %} 5 6 {% block extrastyle %} 7 {{ block.super }} 8 <link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}" /> 9 10 {% for css in dashboard.media.css %} 11 12 {% endfor %} 13 {% endblock %} 14

what is the problem? Thanks

ZeusNabartey avatar Dec 18 '16 12:12 ZeusNabartey

Same behaviour is happening in my case as well. selection_033

rl-yugandhar avatar Jan 09 '17 11:01 rl-yugandhar

Hi Guys,

Have you registered the custom dashboard class properly? I faced the issue because I had wrong class name in config. Its worth checking.

vysakhvasanth avatar Jan 09 '17 14:01 vysakhvasanth

In my case, If it is loading properly for plain customDashboard. Above problem starts after have started integrating 'google-api-python-client'.

rl-yugandhar avatar Jan 09 '17 15:01 rl-yugandhar

Hi ! I'm having the same problem when i try and do the google analytics custom dashboard and i checked my settings.py for mistakes in class name but it's all good, so have any of you found an actual solution to this probem

ThranduilUrMom avatar Mar 17 '17 16:03 ThranduilUrMom

But did you installed the python package?

SalahAdDin avatar Mar 18 '17 14:03 SalahAdDin

@SalahAdDin i think it's one of the first things we had to do according to the tutorial

ThranduilUrMom avatar Mar 18 '17 15:03 ThranduilUrMom

If you want use google analitics you have to install these packages, also i think there are a problem with last version, there are other issue about it.

SalahAdDin avatar Mar 19 '17 19:03 SalahAdDin

I already fixed this problem. Where is the location of your dashboard.py? You should place it in the root directory of your project not together with settings.py. Please reply if that works. Thanks.

On Saturday, March 18, 2017 12:10 AM, Zakariae_Bou-taleb <[email protected]> wrote:

Hi ! I'm having the same problem when i try and do the google analytics custom dashboard and i checked my settings.py for mistakes in class name but it's all good, so have any of you found an actual solution to this probemβ€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

ZeusNabartey avatar Mar 20 '17 05:03 ZeusNabartey

@ZeusNabartey I actually am putting the dashboard.py next to the manage.py file in my project root, but now i'm facing another problem with attaching the google analytics widgets, 'NoReverseMatch at /jet/dashboard/module/16/' i downgraded my google-api-python-client to version 1.4.x and upgraded it to the latest 1.6.x and the error stays in both versions

ThranduilUrMom avatar Mar 22 '17 00:03 ThranduilUrMom

@ZeusNabartey

now i'm facing another problem

Please open another issue for it.

Can I assume you solved the original issue? If so how did you do it?

Ismael-VC avatar Apr 03 '17 19:04 Ismael-VC

Sorry the mention above was meant for @ThranduilUrMom

I'm also having the same problem but only in one server, in my computer everything works fine, then I commit everything and push to repository. Then I cloned on the remote server, ran collectstatic, but it gives me the same error you get.

Ismael-VC avatar Apr 03 '17 20:04 Ismael-VC

Please come to the django-jet Discord server so we can organize if you like:

  • https://discord.gg/3yr5yeH

Welcome! πŸ˜„

Ismael-VC avatar Aug 15 '17 15:08 Ismael-VC

@Ismael-VC could you solve this problem?

SalahAdDin avatar Oct 13 '17 14:10 SalahAdDin

I have this problem too

PaoloC68 avatar Oct 13 '17 14:10 PaoloC68

this is my code:

  
from __future__ import unicode_literals  
from __future__ import absolute_import  
  
from django.core.urlresolvers import reverse  
from django.utils.translation import ugettext_lazy as _  
from jet.dashboard import modules  
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard  
from jet.utils import get_admin_site_name  
  
  
class DefaultIndexDashboard(Dashboard):  
    columns = 3  
  
    def init_with_context(self, context):  
        self.available_children.append(modules.LinkList)  
        self.available_children.append(modules.Feed)  
  
        site_name = get_admin_site_name(context)  
        # append a link list module for "quick links"  
        self.children.append(modules.LinkList(  
            _('Quick links'),  
            layout='inline',  
            draggable=False,  
            deletable=False,  
            collapsible=False,  
            children=[  
                [_('Return to site'), '/'],  
                [_('Change password'),  
                 reverse('%s:password_change' % site_name)],  
                [_('Log out'), reverse('%s:logout' % site_name)],  
            ],  
            column=0,  
            order=0  
        ))  
  
        # append an app list module for "Applications"  
        self.children.append(modules.AppList(  
            _('Applications'),  
            exclude=('auth.*',),  
            column=1,  
            order=0  
        ))  
  
        # append an app list module for "Administration"  
        self.children.append(modules.AppList(  
            _('Administration'),  
            models=('auth.*',),  
            column=2,  
            order=0  
        ))  
  
        # append a recent actions module  
        self.children.append(modules.RecentActions(  
            _('Recent Actions'),  
            10,  
            column=0,  
            order=1  
        ))  
  
        # append a feed module  
        self.children.append(modules.Feed(  
            _('Latest Django News'),  
            feed_url='http://www.djangoproject.com/rss/weblog/',  
            limit=5,  
            column=1,  
            order=1  
        ))  
  
        # append another link list module for "support".  
        self.children.append(modules.LinkList(  
            _('Support'),  
            children=[  
                {  
                    'title': _('Django documentation'),  
                    'url': 'http://docs.djangoproject.com/',  
                    'external': True,  
                },  
                {  
                    'title': _('Django "django-users" mailing list'),  
                    'url': 'http://groups.google.com/group/django-users',  
                    'external': True,  
                },  
                {  
                    'title': _('Django irc channel'),  
                    'url': 'irc://irc.freenode.net/django',  
                    'external': True,  
                },  
            ],  
            column=2,  
            order=1  
        ))

and in the settings: JET_INDEX_DASHBOARD = 'dashboard.DefaultIndexDashboard'

Which is exactly the same code as the one provided with the package

PaoloC68 avatar Oct 13 '17 14:10 PaoloC68

Once put the custom dashboard code within an app it worked, until in the project folder I got this issue

PaoloC68 avatar Oct 13 '17 15:10 PaoloC68

I want confirm same behaviour and same solution as ZeusNabartey, when you try follow the basic django-jet documentation: dashboard,py should be placed together with manage.py, not together with settings.py.

zvolsky avatar Jan 27 '18 22:01 zvolsky

@zvolsky Can you put this in the docs? And, is it the same for production?

SalahAdDin avatar Jan 27 '18 22:01 SalahAdDin

I made the proposal through jet.readthedocs.io, which have created PRΒ  https://github.com/geex-arts/django-jet/pull/288

I have no production server for this, it was just learning of the dashboard use.

Best regards,

Mirek

---------- PΕ―vodnΓ­ e-mail ---------- Od: JosΓ© Luis [email protected] Komu: geex-arts/django-jet [email protected] Datum: 27. 1. 2018 23:31:36 PΕ™edmΔ›t: Re: [geex-arts/django-jet] Cant load custom dashboard (#156) " @zvolsky(https://github.com/zvolsky) Can you put this in the docs? And, is it the same for production?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/geex-arts/django-jet/issues/156#issuecomment-361020737), or mute the thread (https://github.com/notifications/unsubscribe-auth/AA-ubtA8x5yuzDO7IrMUly5LzmgyuqC5ks5tO6PDgaJpZM4LQHjX) .

"

zvolsky avatar Jan 28 '18 00:01 zvolsky

So hours later the fix is both moving jet_dashboard.py / whatever you want to call it next to manage.py and for some reason you can't use a custom side JET_MENU, it's just going to crash later on.

expresspotato avatar Feb 05 '19 19:02 expresspotato

I faced this issue when the pygal dependency was not installed.

pip install pygal

fixed it

danihodovic avatar Jun 20 '19 04:06 danihodovic

is it required for the new version?

SalahAdDin avatar Jun 20 '19 15:06 SalahAdDin

Managed to fix this and keep dashboard.py in my app folder:

.
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ dashboard.py
β”‚   β”œβ”€β”€ settings.py
β”‚   └── ...
└── manage.py

and then in my settings.py:

JET_INDEX_DASHBOARD = 'app.dashboard.CustomIndexDashboard'

DavidLemayian avatar Jan 24 '20 11:01 DavidLemayian

Managed to fix this and keep dashboard.py in my app folder:

.
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ dashboard.py
β”‚   β”œβ”€β”€ settings.py
β”‚   └── ...
└── manage.py

and then in my settings.py:

JET_INDEX_DASHBOARD = 'app.dashboard.CustomIndexDashboard'

This fixed it for me, i forgot to add the app. in the JET_INDEX_DASHBOARD constant.

nxb303 avatar Feb 11 '20 10:02 nxb303

Managed to fix this and keep dashboard.py in my app folder:

.
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ dashboard.py
β”‚   β”œβ”€β”€ settings.py
β”‚   └── ...
└── manage.py

and then in my settings.py:

JET_INDEX_DASHBOARD = 'app.dashboard.CustomIndexDashboard'

This works for me

Fanevanjanahary avatar Aug 04 '20 06:08 Fanevanjanahary

It worked for me deleting the word index Setting .py

JET_DASHBOARD = 'app.dashboard.CustomIndexDashboard'

brian-emarquez avatar Oct 28 '22 21:10 brian-emarquez

It worked for me deleting the word index Setting .py

JET_DASHBOARD = 'app.dashboard.CustomIndexDashboard'

This indeed stopped throwing error, but it wasn't loading my CustomIndexDashboard. I am using django-4-jet

Even though the error was 'NoneType' object is not callable but the underlying issue was different and took me a while to get to it. There is an ImportError in CustomIndexDashboard, you see its trying to import from django.utils.translation import ugettext_lazy as _ but django==4 (haven't tested django==3) doesn't export ugettext_lazy from django.utils.translation anymore.

Solution: use gettext_lazy from django.utils.translation import gettext_lazy as _ and it should be working.

Do not forget to reload widgets (refresh button in top right corner in admin console), otherwise the changes or your custom dashboard and its widgets will not be visible

jayantamadhav avatar Feb 27 '23 14:02 jayantamadhav

I am also getting same error when clicking on admin module. can anyone suggest how to resolve?? Screenshot from 2023-03-14 11-48-38

RajatHcode avatar Mar 14 '23 06:03 RajatHcode