I am sorry for this novice question. I tried to find out difference between select_related() and select_related('ColumnName'). Is there difference between these two ?
I am trying to understand this post in which author emphasizing to use select_related('content_type').all() rather than simple select_related().all(). Your help will be appreciated since from last two hours I am struggling to grasp this concept.
Thank you very much,
Sunil
From the django docs, when called with no arguments:
Returns a QuerySet that will automatically "follow" foreign-key relationships, selecting that additional related-object data when it executes its query.
When given an argument:
Sometimes you only want to access specific models that are related to your root model, not all of the related models. In these cases, you can pass the related field names to select_related() and it will only follow those relations. You can even do this for models that are more than one relation away by separating the field names with double underscores, just as for filters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With