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!
Written by Andy Mroczkowski
Related protips
1 Response
Yes! Thank you!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#