diff options
| author | Tom Christie | 2014-11-28 09:57:02 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-11-28 09:57:02 +0000 |
| commit | d4b8e356b952137760bf33750b17895526d6151e (patch) | |
| tree | cb4428b2967582dd8ca50cb1bcd1f7bb95b1fe5f /rest_framework | |
| parent | d2d7e1dfde2a62ee8f6d904368dbd6581de278c9 (diff) | |
| parent | 34ca8cd2a5c030d9acc89720876ba9583c1dc988 (diff) | |
| download | django-rest-framework-d4b8e356b952137760bf33750b17895526d6151e.tar.bz2 | |
Merge branch '3.0-docs'
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/relations.py | 19 | ||||
| -rw-r--r-- | rest_framework/request.py | 2 | ||||
| -rw-r--r-- | rest_framework/serializers.py | 4 |
3 files changed, 22 insertions, 3 deletions
diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 79c8057b..d1ea497a 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -49,6 +49,21 @@ class RelatedField(Field): @classmethod def many_init(cls, *args, **kwargs): + """ + This method handles creating a parent `ManyRelatedField` instance + when the `many=True` keyword argument is passed. + + Typically you won't need to override this method. + + Note that we're over-cautious in passing most arguments to both parent + and child classes in order to try to cover the general case. If you're + overriding this method you'll probably want something much simpler, eg: + + @classmethod + def many_init(cls, *args, **kwargs): + kwargs['child'] = cls() + return CustomManyRelatedField(*args, **kwargs) + """ list_kwargs = {'child_relation': cls(*args, **kwargs)} for key in kwargs.keys(): if key in MANY_RELATION_KWARGS: @@ -306,7 +321,9 @@ class ManyRelatedField(Field): The `ManyRelatedField` class is responsible for handling iterating through the values and passing each one to the child relationship. - You shouldn't need to be using this class directly yourself. + This class is treated as private API. + You shouldn't generally need to be using this class directly yourself, + and should instead simply set 'many=True' on the relationship. """ initial = [] default_empty_html = [] diff --git a/rest_framework/request.py b/rest_framework/request.py index 096b3042..d7e74674 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -310,7 +310,7 @@ class Request(object): def _load_data_and_files(self): """ - Parses the request content into self.DATA and self.FILES. + Parses the request content into `self.data`. """ if not _hasattr(self, '_content_type'): self._load_method_and_content_type() diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index e86e67f7..f7aa3a7d 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -102,7 +102,9 @@ class BaseSerializer(Field): (key, value) for key, value in kwargs.items() if key in LIST_SERIALIZER_KWARGS ])) - return ListSerializer(*args, **list_kwargs) + meta = getattr(cls, 'Meta', None) + list_serializer_class = getattr(meta, 'list_serializer_class', ListSerializer) + return list_serializer_class(*args, **list_kwargs) def to_internal_value(self, data): raise NotImplementedError('`to_internal_value()` must be implemented.') |
