mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 01:49:50 +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)
|
||||
except ObjectDoesNotExist:
|
||||
return None
|
||||
if instance == None:
|
||||
return None
|
||||
if is_simple_callable(instance):
|
||||
try:
|
||||
instance = instance()
|
||||
|
|
Loading…
Reference in New Issue
Block a user