[Fixed]-How to force select_related() to select ForeignKeys that have null=True attribute?


Yes, that is the way you would go about selecting related items with null=True.

Straight from the docs for select_related:

You can refer to any ForeignKey or OneToOneField relation in the list of fields passed to select_related. Ths includes foreign keys that have null=True (unlike the default select_related() call).

Is there a reason you need a different way to perform this action? If not, you have it right already.

Leave a comment