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/relations.py | |
| parent | d2d7e1dfde2a62ee8f6d904368dbd6581de278c9 (diff) | |
| parent | 34ca8cd2a5c030d9acc89720876ba9583c1dc988 (diff) | |
| download | django-rest-framework-d4b8e356b952137760bf33750b17895526d6151e.tar.bz2 | |
Merge branch '3.0-docs'
Diffstat (limited to 'rest_framework/relations.py')
| -rw-r--r-- | rest_framework/relations.py | 19 |
1 files changed, 18 insertions, 1 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 = [] |
