You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why can't we just allow some customization at this line? Usually with any toolbox, we provide a best effort default and give the user the option to customize. In this case, the relations will ALWAYS be fetched with .all(). I have a simple case where I need an annotation on each child and so a single query is enough, if done on the ManyRelatedField level. How about making the ManyRelatedField also accept a queryset argument and default to .all() if there is no queryset argument?
The text was updated successfully, but these errors were encountered:
class ManyRelatedField(Field):
...
queryset = None
def __init__(self, child_relation=None, *args, **kwargs):
self.queryset = kwargs.pop('queryset', self.queryset)
...
def get_attribute(self, instance):
# If a custom queryset has been set, use that before falling back to the best effort
if self.queryset:
return self.queryset
...
This is linked to #4917
django-rest-framework/rest_framework/relations.py
Line 561 in 4c7c693
Why can't we just allow some customization at this line? Usually with any toolbox, we provide a best effort default and give the user the option to customize. In this case, the relations will ALWAYS be fetched with
.all()
. I have a simple case where I need an annotation on each child and so a single query is enough, if done on theManyRelatedField
level. How about making theManyRelatedField
also accept aqueryset
argument and default to.all()
if there is noqueryset
argument?The text was updated successfully, but these errors were encountered: