mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Merge f5d6925312
into 6831472a62
This commit is contained in:
commit
7a83a0ce44
|
@ -14,6 +14,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import copy
|
||||
import inspect
|
||||
import re
|
||||
import traceback
|
||||
from collections import Mapping, OrderedDict
|
||||
|
||||
|
@ -367,10 +368,20 @@ class Serializer(BaseSerializer):
|
|||
|
||||
@cached_property
|
||||
def _writable_fields(self):
|
||||
return [
|
||||
field for field in self.fields.values()
|
||||
if (not field.read_only) or (field.default is not empty)
|
||||
]
|
||||
ret = []
|
||||
for field in self.fields.values():
|
||||
if re.compile("\_set$").findall(field.source):
|
||||
try:
|
||||
for field in field.child._writable_fields:
|
||||
if (not field.read_only) or (field.default is not empty):
|
||||
ret.append(field)
|
||||
except:
|
||||
if (not field.read_only) or (field.default is not empty):
|
||||
ret.append(field)
|
||||
continue
|
||||
if (not field.read_only) or (field.default is not empty):
|
||||
ret.append(field)
|
||||
return ret
|
||||
|
||||
@cached_property
|
||||
def _readable_fields(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user