Skip to content

Commit fd97d9b

Browse files
committed
Use select inputs for relationships. Closes #2058.
1 parent ea98de9 commit fd97d9b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

rest_framework/relations.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def __init__(self, **kwargs):
3434

3535
def __new__(cls, *args, **kwargs):
3636
# We override this method in order to automagically create
37-
# `ManyRelation` classes instead when `many=True` is set.
37+
# `ManyRelatedField` classes instead when `many=True` is set.
3838
if kwargs.pop('many', False):
3939
list_kwargs = {'child_relation': cls(*args, **kwargs)}
4040
for key in kwargs.keys():
4141
if key in MANY_RELATION_KWARGS:
4242
list_kwargs[key] = kwargs[key]
43-
return ManyRelation(**list_kwargs)
43+
return ManyRelatedField(**list_kwargs)
4444
return super(RelatedField, cls).__new__(cls, *args, **kwargs)
4545

4646
def run_validation(self, data=empty):
@@ -286,12 +286,12 @@ def to_representation(self, obj):
286286
return getattr(obj, self.slug_field)
287287

288288

289-
class ManyRelation(Field):
289+
class ManyRelatedField(Field):
290290
"""
291291
Relationships with `many=True` transparently get coerced into instead being
292-
a ManyRelation with a child relationship.
292+
a ManyRelatedField with a child relationship.
293293
294-
The `ManyRelation` class is responsible for handling iterating through
294+
The `ManyRelatedField` class is responsible for handling iterating through
295295
the values and passing each one to the child relationship.
296296
297297
You shouldn't need to be using this class directly yourself.
@@ -302,7 +302,7 @@ class ManyRelation(Field):
302302
def __init__(self, child_relation=None, *args, **kwargs):
303303
self.child_relation = child_relation
304304
assert child_relation is not None, '`child_relation` is a required argument.'
305-
super(ManyRelation, self).__init__(*args, **kwargs)
305+
super(ManyRelatedField, self).__init__(*args, **kwargs)
306306
self.child_relation.bind(field_name='', parent=self)
307307

308308
def get_value(self, dictionary):

rest_framework/renderers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@ class HTMLFormRenderer(BaseRenderer):
383383
serializers.MultipleChoiceField: {
384384
'base_template': 'select_multiple.html', # Also valid: 'checkbox_multiple.html'
385385
},
386-
serializers.ManyRelation: {
386+
serializers.RelatedField: {
387+
'base_template': 'select.html', # Also valid: 'radio.html'
388+
},
389+
serializers.ManyRelatedField: {
387390
'base_template': 'select_multiple.html', # Also valid: 'checkbox_multiple.html'
388391
},
389392
serializers.Serializer: {

0 commit comments

Comments
 (0)