Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable HTML inputs for dict/list fields #5702

Merged
merged 1 commit into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rest_framework/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ class HTMLFormRenderer(BaseRenderer):
serializers.ListSerializer: {
'base_template': 'list_fieldset.html'
},
serializers.ListField: {
'base_template': 'list_field.html'
},
serializers.DictField: {
'base_template': 'dict_field.html'
},
serializers.FilePathField: {
'base_template': 'select.html',
},
Expand Down
11 changes: 11 additions & 0 deletions rest_framework/templates/rest_framework/horizontal/dict_field.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="form-group">
{% if field.label %}
<label class="col-sm-2 control-label {% if style.hide_label %}sr-only{% endif %}">
{{ field.label }}
</label>
{% endif %}

<div class="col-sm-10">
<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
</div>
</div>
11 changes: 11 additions & 0 deletions rest_framework/templates/rest_framework/horizontal/list_field.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="form-group">
{% if field.label %}
<label class="col-sm-2 control-label {% if style.hide_label %}sr-only{% endif %}">
{{ field.label }}
</label>
{% endif %}

<div class="col-sm-10">
<p class="form-control-static">Lists are not currently supported in HTML input.</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="form-group">
{% if field.label %}
<label class="sr-only">
{{ field.label }}
</label>
{% endif %}

<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="form-group">
{% if field.label %}
<label class="sr-only">
{{ field.label }}
</label>
{% endif %}

<p class="form-control-static">Lists are not currently supported in HTML input.</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="form-group">
{% if field.label %}
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
{% endif %}

<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="form-group">
{% if field.label %}
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
{% endif %}

<p class="form-control-static">Lists are not currently supported in HTML input.</p>
</div>