mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-31 10:30:01 +03:00
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:
parent
b25d245b89
commit
296ebc5c27
|
@ -101,6 +101,8 @@ def get_attribute(instance, attrs):
|
||||||
instance = getattr(instance, attr)
|
instance = getattr(instance, attr)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
return None
|
return None
|
||||||
|
if instance == None:
|
||||||
|
return None
|
||||||
if is_simple_callable(instance):
|
if is_simple_callable(instance):
|
||||||
try:
|
try:
|
||||||
instance = instance()
|
instance = instance()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user