aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/relations.py
diff options
context:
space:
mode:
authorTom Christie2014-11-26 11:30:28 +0000
committerTom Christie2014-11-26 11:30:28 +0000
commitb4550c65dd339731ff3dd2b0dd3c6dad12565906 (patch)
tree494d9841ce5d1db87df2e82f1e3b68a4d2d5bd87 /rest_framework/relations.py
parent678f7b4c654ccc1bc147d36e0ecb4a3a3a1cacdb (diff)
downloaddjango-rest-framework-b4550c65dd339731ff3dd2b0dd3c6dad12565906.tar.bz2
Docstring for 'many_init'
Diffstat (limited to 'rest_framework/relations.py')
-rw-r--r--rest_framework/relations.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/rest_framework/relations.py b/rest_framework/relations.py
index 79c8057b..5a3403f5 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: