About Using Select Related in Model Admin
Use list_select_related
with the model admin, to tell administration to select related foreign keys.
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
list_display = ["title", "category"]
list_select_related = True
Here are some common values of list_select_related
:
False
(default) means thatselect_related()
is only used for the foreign keys listed in thelist_display
.True
means thatselect_related()
is used for all foreign keys.["category"]
means thatselect_related()
is used only for thecategory
field.[]
means thatselect_related()
is not used.
Tips and Tricks Databases Performance Django 5.2 Django 4.2 Django 3.2 PostgreSQL MySQL SQLite
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.