ppqusg
Last Updated: January 23, 2019
·
3.285K
· amrox

Slow admin pages in Django?

If a model has a relationship to another model, the Django admin will include a drop-down list automatically. While convenient, this can be a big performance hit because it needs to load every object.

You can solve this by using raw_id_fields on the admin model. For example, instead of:

admin.site.register(Widget)

Do something like:

class WidgetAdmin(admin.ModelAdmin):
    raw_id_fields = ('user',)

admin.site.register(Widget, WidgetAdmin)

and performance should be greatly improved!

1 Response
Add your response

12633

Yes! Thank you!

over 1 year ago ·