When i using the source function of serializers there was a problem, the source of a foreign key field will give me an error named incorrectly and not match any attribute, the foreign key is correct, but I just haven't add data, it is clearly wrong, so I modified the code, let it out key correctly and without adding data return None

This commit is contained in:
5505005 2019-03-26 22:06:01 +08:00
parent b25d245b89
commit 296ebc5c27

View File

@ -101,6 +101,8 @@ def get_attribute(instance, attrs):
instance = getattr(instance, attr)
except ObjectDoesNotExist:
return None
if instance == None:
return None
if is_simple_callable(instance):
try:
instance = instance()