mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 05:20:12 +03:00
Fix TypeError: 'NoneType' object is not iterable
There is some cases that ``self.child_relation.queryset`` is None (in a ManyToManyField for example) instead a empty list/QuerySet
This commit is contained in:
parent
0a805d979d
commit
d470a2c173
|
@ -365,7 +365,7 @@ class ManyRelatedField(Field):
|
|||
@property
|
||||
def choices(self):
|
||||
queryset = self.child_relation.queryset
|
||||
iterable = queryset.all() if (hasattr(queryset, 'all')) else queryset
|
||||
iterable = queryset.all() if (hasattr(queryset, 'all')) else queryset or []
|
||||
items_and_representations = [
|
||||
(item, self.child_relation.to_representation(item))
|
||||
for item in iterable
|
||||
|
|
Loading…
Reference in New Issue
Block a user