[Fixed]-How to use select_related with GenericForeignKey in django?

39👍

It is not select_related what you are looking for. It is prefetch_related, which

supports prefetching of GenericRelation and GenericForeignKey.

Therefore, your base command would be:

Offer.objects.all().prefetch_related('content_object')

Leave a comment