mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
Allow ModelSerializers as children in ListField
This commit is contained in:
parent
0e10d32fb1
commit
417c1d47e4
|
@ -19,6 +19,7 @@ from django.core.validators import (
|
||||||
from django.forms import FilePathField as DjangoFilePathField
|
from django.forms import FilePathField as DjangoFilePathField
|
||||||
from django.forms import ImageField as DjangoImageField
|
from django.forms import ImageField as DjangoImageField
|
||||||
from django.utils import six, timezone
|
from django.utils import six, timezone
|
||||||
|
from django.db import models
|
||||||
from django.utils.dateparse import (
|
from django.utils.dateparse import (
|
||||||
parse_date, parse_datetime, parse_duration, parse_time
|
parse_date, parse_datetime, parse_duration, parse_time
|
||||||
)
|
)
|
||||||
|
@ -1653,7 +1654,8 @@ class ListField(Field):
|
||||||
"""
|
"""
|
||||||
List of object instances -> List of dicts of primitive datatypes.
|
List of object instances -> List of dicts of primitive datatypes.
|
||||||
"""
|
"""
|
||||||
return [self.child.to_representation(item) if item is not None else None for item in data]
|
items = data.all() if isinstance(data, models.Manager) else data
|
||||||
|
return [self.child.to_representation(item) if item is not None else None for item in items]
|
||||||
|
|
||||||
def run_child_validation(self, data):
|
def run_child_validation(self, data):
|
||||||
result = []
|
result = []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user