[Answered ]-Avoiding multiple queries to display model data on Django admin

2👍

You should use the list_select_related option on the ModelAdmin to tell Django to do a JOIN query.

class MeaningAdmin(admin.ModelAdmin):
    list_select_related = ('word_id',)

(Note, you really shouldn’t call your FK fields things like word_id. The field gives access to an actual instance of Word, so it should just be called word; the underlying db column will automatically be called word_id.)

Leave a comment