Change group in Django admin is very slow

Viewed 883

Django 1.11

If I click Groups in Django admin site, I can see a list of groups. Namely, the address is http://localhost:8000/admin/auth/group/

I monitor the CPU usage in terminal. Python is consuming 4-5 % now.

I have organized 4 groups. So, if I click any group, the server just calculating something for several minutes. The address now is like http://localhost:8000/admin/auth/group/6/change/ Maybe about 5 minutes the server is calculating something. And Python is now consuming 100 % of CPU resources.

Well, Django admin is analyzing something.

I have about 23-25 models. Well, this is not a very big number of models.

Each model is 3 standard permissions (add, change, delete). And I created one permission myself in the Meta class of a model.

So, as soon as "Change group" page is in front of me with available permissions and chosen permissions, CPU consumption by Python is again 4-5 %.

Could you comment on this? Is it curable?

4 Answers

Came across this issue when using django debug toolbar with the built in django admin app. The change/update page was incredibly slow locally (sometimes it would not load at all) but if I set DEBUG=False (thus turning the debug toolbar off) it worked as expected. In my particular case, I didn't need the debug toolbar for the admin app so I disabled it for only those admin URLS like so:

# settings.py

DEBUG = True

def show_toolbar(request):
    # disable debug toolbar for built in admin app urls only
    if request.path.startswith('/admin'):
        return False
    else:
        return True
DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': show_toolbar,
}

We're using the same setup as Max Malysh:

  • Django 1.11
  • A custom User model based on django.contrib.auth.models.AbstractUser
  • The custom user model set in the settings via AUTH_USER_MODEL variable

We've got the same issues and I think I found the issue, or at least the module which is causing the delays. It has nothing to do with Django and/or the DEBUG mode itself, because I think the issue is within the debug_toolbar.

If you deactivate the debug_toolbar application and debug_toolbar.middleware.DebugToolbarMiddleware middleware, it works like a charm.

I didn't had the time to reverse-engineer it, but I'll have a look at it when I find the time. In the meantime and as a workaround, deactivate the debug toolbar if you don't need it.

Sorry, it's not a final solution yet, but I thought I'll share my findings in case they can help somebody.

Cheers Domi

EDIT/UPDATE: It has something to do with the Template panel of the Debug Toolbar. If you deactivate it, you'll have a much faster response time!

I was experiencing this same problem, but probably for a different reason than the OP was.

If you have a large number of Users, look at your admin.py and make sure that you are not displaying Users inline on the Group admin page. That can cause very slow loading of the Group admin page if the Group has a large number of users in it.

Related