Merge pull request #652 from taigaio/luyikei-avoid-none

Avoid accessing an attribute of a NoneType object
remotes/origin/issue/4795/notification_even_they_are_disabled
Alejandro 2016-03-03 10:06:08 +01:00
commit cc4f82f7cd
1 changed files with 7 additions and 6 deletions

View File

@ -239,7 +239,8 @@ class EditableWatchedResourceModelSerializer(WatchedResourceModelSerializer):
def to_native(self, obj):
#if watchers wasn't attached via the get_queryset of the viewset we need to manually add it
if obj is not None and not hasattr(obj, "watchers"):
if obj is not None:
if not hasattr(obj, "watchers"):
obj.watchers = [user.id for user in obj.get_watchers()]
request = self.context.get("request", None)