aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rest_framework/renderers.py15
-rw-r--r--rest_framework/serializers.py4
-rw-r--r--rest_framework/templates/rest_framework/fields/attrs.html1
-rw-r--r--rest_framework/templates/rest_framework/fields/horizontal/input.html7
-rw-r--r--rest_framework/templates/rest_framework/fields/horizontal/label.html1
-rw-r--r--rest_framework/templates/rest_framework/fields/horizontal/textarea.html7
-rw-r--r--rest_framework/templates/rest_framework/fields/inline/input.html4
-rw-r--r--rest_framework/templates/rest_framework/fields/inline/label.html1
-rw-r--r--rest_framework/templates/rest_framework/fields/inline/textarea.html4
-rw-r--r--rest_framework/templates/rest_framework/fields/vertical/input.html5
-rw-r--r--rest_framework/templates/rest_framework/fields/vertical/label.html1
-rw-r--r--rest_framework/templates/rest_framework/fields/vertical/textarea.html5
-rw-r--r--rest_framework/templates/rest_framework/form.html33
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/checkbox.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/checkbox.html)0
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/fieldset.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/fieldset.html)0
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/input.html9
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html)0
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/select.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/select.html)8
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html)4
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html)4
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/select_radio.html (renamed from rest_framework/templates/rest_framework/fields/horizontal/select_radio.html)4
-rw-r--r--rest_framework/templates/rest_framework/horizontal/fields/textarea.html9
-rw-r--r--rest_framework/templates/rest_framework/horizontal/form.html15
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/checkbox.html (renamed from rest_framework/templates/rest_framework/fields/inline/checkbox.html)0
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/fieldset.html (renamed from rest_framework/templates/rest_framework/fields/inline/fieldset.html)0
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/input.html6
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/select.html (renamed from rest_framework/templates/rest_framework/fields/inline/select.html)4
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/select_checkbox.html (renamed from rest_framework/templates/rest_framework/fields/inline/select_checkbox.html)4
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/select_multiple.html (renamed from rest_framework/templates/rest_framework/fields/vertical/select_multiple.html)4
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/select_radio.html (renamed from rest_framework/templates/rest_framework/fields/inline/select_radio.html)4
-rw-r--r--rest_framework/templates/rest_framework/inline/fields/textarea.html6
-rw-r--r--rest_framework/templates/rest_framework/inline/form.html11
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/checkbox.html (renamed from rest_framework/templates/rest_framework/fields/vertical/checkbox.html)0
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/fieldset.html (renamed from rest_framework/templates/rest_framework/fields/vertical/fieldset.html)0
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/input.html7
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html (renamed from rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html)0
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/select.html (renamed from rest_framework/templates/rest_framework/fields/vertical/select.html)4
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html (renamed from rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html)4
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/select_multiple.html (renamed from rest_framework/templates/rest_framework/fields/inline/select_multiple.html)4
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/select_radio.html (renamed from rest_framework/templates/rest_framework/fields/vertical/select_radio.html)4
-rw-r--r--rest_framework/templates/rest_framework/vertical/fields/textarea.html7
-rw-r--r--rest_framework/templates/rest_framework/vertical/form.html11
-rw-r--r--rest_framework/templatetags/rest_framework.py4
43 files changed, 127 insertions, 98 deletions
diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py
index 4fb36060..5fae75f2 100644
--- a/rest_framework/renderers.py
+++ b/rest_framework/renderers.py
@@ -339,7 +339,6 @@ class HTMLFormRenderer(BaseRenderer):
"""
media_type = 'text/html'
format = 'form'
- template = 'rest_framework/form.html'
charset = 'utf-8'
field_templates = ClassLookupDict({
@@ -383,26 +382,21 @@ class HTMLFormRenderer(BaseRenderer):
serializers.TimeField: 'time',
})
- def render_field(self, field, layout=None):
- layout = layout or 'vertical'
+ def render_field(self, field, template_pack=None):
style_type = field.style.get('type', 'default')
- if style_type == 'textarea' and layout == 'inline':
- style_type = 'default'
input_type = self.input_type[field]
if input_type == 'datetime-local' and isinstance(field.value, six.text_type):
field.value = field.value.rstrip('Z')
base = self.field_templates[field][style_type]
- template_name = 'rest_framework/fields/' + layout + '/' + base
+ template_name = template_pack + '/fields/' + base
template = loader.get_template(template_name)
context = Context({
'field': field,
'input_type': input_type,
'renderer': self,
- 'layout': layout
})
-
return template.render(context)
def render(self, data, accepted_media_type=None, renderer_context=None):
@@ -411,11 +405,10 @@ class HTMLFormRenderer(BaseRenderer):
"""
renderer_context = renderer_context or {}
request = renderer_context['request']
-
- template = loader.get_template(self.template)
+ template = loader.get_template('rest_framework/horizontal/form.html')
context = RequestContext(request, {
'form': data.serializer,
- 'layout': getattr(getattr(data, 'Meta', None), 'layout', 'horizontal'),
+ 'template_pack': 'rest_framework/horizontal',
'renderer': self
})
return template.render(context)
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index bc9c15eb..c844605f 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -680,7 +680,7 @@ class ModelSerializer(Serializer):
PendingDeprecationWarning,
stacklevel=3
)
- kwargs = extra_kwargs.get(field_name, {})
+ kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
kwargs['view_name'] = view_name
extra_kwargs[api_settings.URL_FIELD_NAME] = kwargs
@@ -692,7 +692,7 @@ class ModelSerializer(Serializer):
PendingDeprecationWarning,
stacklevel=3
)
- kwargs = extra_kwargs.get(field_name, {})
+ kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
kwargs['lookup_field'] = lookup_field
extra_kwargs[api_settings.URL_FIELD_NAME] = kwargs
diff --git a/rest_framework/templates/rest_framework/fields/attrs.html b/rest_framework/templates/rest_framework/fields/attrs.html
deleted file mode 100644
index 1e23c465..00000000
--- a/rest_framework/templates/rest_framework/fields/attrs.html
+++ /dev/null
@@ -1 +0,0 @@
-name="{{ field.name }}" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.style.rows %}rows="{{ field.style.rows }}"{% endif %}
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/input.html b/rest_framework/templates/rest_framework/fields/horizontal/input.html
deleted file mode 100644
index 6f1a504b..00000000
--- a/rest_framework/templates/rest_framework/fields/horizontal/input.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<div class="form-group">
- {% include "rest_framework/fields/horizontal/label.html" %}
- <div class="col-sm-10">
- <input type="{{ input_type }}" class="form-control" {% include "rest_framework/fields/attrs.html" %} {% if field.value %}value="{{ field.value }}"{% endif %}>
- {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
- </div>
-</div>
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/label.html b/rest_framework/templates/rest_framework/fields/horizontal/label.html
deleted file mode 100644
index bf21f78c..00000000
--- a/rest_framework/templates/rest_framework/fields/horizontal/label.html
+++ /dev/null
@@ -1 +0,0 @@
-{% if field.label %}<label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>{% endif %}
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/textarea.html b/rest_framework/templates/rest_framework/fields/horizontal/textarea.html
deleted file mode 100644
index 3d016195..00000000
--- a/rest_framework/templates/rest_framework/fields/horizontal/textarea.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<div class="form-group">
- {% include "rest_framework/fields/horizontal/label.html" %}
- <div class="col-sm-10">
- <textarea class="form-control" {% include "rest_framework/fields/attrs.html" %}>{% if field.value %}{{ field.value }}{% endif %}</textarea>
- {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
- </div>
-</div>
diff --git a/rest_framework/templates/rest_framework/fields/inline/input.html b/rest_framework/templates/rest_framework/fields/inline/input.html
deleted file mode 100644
index e4a92ccd..00000000
--- a/rest_framework/templates/rest_framework/fields/inline/input.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<div class="form-group">
- {% include "rest_framework/fields/inline/label.html" %}
- <input type="{{ input_type }}" class="form-control" {% include "rest_framework/fields/attrs.html" %} {% if field.value %}value="{{ field.value }}"{% endif %}>
-</div>
diff --git a/rest_framework/templates/rest_framework/fields/inline/label.html b/rest_framework/templates/rest_framework/fields/inline/label.html
deleted file mode 100644
index 7d546a57..00000000
--- a/rest_framework/templates/rest_framework/fields/inline/label.html
+++ /dev/null
@@ -1 +0,0 @@
-{% if field.label %}<label class="sr-only">{{ field.label }}</label>{% endif %}
diff --git a/rest_framework/templates/rest_framework/fields/inline/textarea.html b/rest_framework/templates/rest_framework/fields/inline/textarea.html
deleted file mode 100644
index 8259487b..00000000
--- a/rest_framework/templates/rest_framework/fields/inline/textarea.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<div class="form-group">
- {% include "rest_framework/fields/inline/label.html" %}
- <textarea class="form-control" {% include "rest_framework/fields/attrs.html" %}>{% if field.value %}{{ field.value }}{% endif %}</textarea>
-</div>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/input.html b/rest_framework/templates/rest_framework/fields/vertical/input.html
deleted file mode 100644
index 3ee2716a..00000000
--- a/rest_framework/templates/rest_framework/fields/vertical/input.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="form-group">
- {% include "rest_framework/fields/vertical/label.html" %}
- <input type="{{ input_type }}" class="form-control" {% include "rest_framework/fields/attrs.html" %} {% if field.value %}value="{{ field.value }}"{% endif %}>
- {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
-</div>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/label.html b/rest_framework/templates/rest_framework/fields/vertical/label.html
deleted file mode 100644
index 651939b2..00000000
--- a/rest_framework/templates/rest_framework/fields/vertical/label.html
+++ /dev/null
@@ -1 +0,0 @@
-{% if field.label %}<label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>{% endif %}
diff --git a/rest_framework/templates/rest_framework/fields/vertical/textarea.html b/rest_framework/templates/rest_framework/fields/vertical/textarea.html
deleted file mode 100644
index 406cfa77..00000000
--- a/rest_framework/templates/rest_framework/fields/vertical/textarea.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="form-group">
- {% include "rest_framework/fields/vertical/label.html" %}
- <textarea class="form-control" {% include "rest_framework/fields/attrs.html" %}>{% if field.value %}{{ field.value }}{% endif %}</textarea>
- {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
-</div>
diff --git a/rest_framework/templates/rest_framework/form.html b/rest_framework/templates/rest_framework/form.html
deleted file mode 100644
index 162c5633..00000000
--- a/rest_framework/templates/rest_framework/form.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!-- <html>
-<head>
- <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
-</head>
-<body>
-<div class="container">
-
-<h1>User update</h1>
-<div class="well"> -->
-
-{% load rest_framework %}
-<form {% if layout == "inline" %}class="form-inline"{% elif layout == "horizontal" %}class="form-horizontal"{% endif %} role="form" action="." method="POST">
- {% csrf_token %}
- {% for field in form %}
- {% if not field.read_only %}
- {% render_field field layout=layout renderer=renderer %}
- {% endif %}
- {% endfor %}
- <!-- form.non_field_errors -->
- {% if layout == "horizontal" %}
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <button type="submit" class="btn btn-default">Submit</button>
- </div>
- </div>
- {% else %}
- <button type="submit" class="btn btn-default">Submit</button>
- {% endif %}
-</form>
-<!--
-</div>
-</div></body>
-</html> -->
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/checkbox.html b/rest_framework/templates/rest_framework/horizontal/fields/checkbox.html
index ee3bf936..ee3bf936 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/checkbox.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/checkbox.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/fieldset.html b/rest_framework/templates/rest_framework/horizontal/fields/fieldset.html
index ff93c6ba..ff93c6ba 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/fieldset.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/fieldset.html
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/input.html b/rest_framework/templates/rest_framework/horizontal/fields/input.html
new file mode 100644
index 00000000..6621c7e6
--- /dev/null
+++ b/rest_framework/templates/rest_framework/horizontal/fields/input.html
@@ -0,0 +1,9 @@
+<div class="form-group">
+ {% if field.label %}
+ <label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
+ {% endif %}
+ <div class="col-sm-10">
+ <input name="{{ field.name }}" type="{{ input_type }}" class="form-control" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %}>
+ {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
+ </div>
+</div>
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html b/rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html
index 68c75d4f..68c75d4f 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select.html b/rest_framework/templates/rest_framework/horizontal/fields/select.html
index 10b4b139..eaa6d575 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/select.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/select.html
@@ -1,10 +1,12 @@
<div class="form-group">
- {% include "rest_framework/fields/horizontal/label.html" %}
+ {% if field.label %}
+ <label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
+ {% endif %}
<div class="col-sm-10">
<select class="form-control" name="{{ field.name }}">
- {% for key, text in field.choices.items %}
+ {% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option>
- {% endfor %}
+ {% endfor %}
</select>
</div>
</div>
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html b/rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html
index 6041fa74..ff3fab57 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/horizontal/label.html" %}
+ {% if field.label %}
+ <label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
+ {% endif %}
<div class="col-sm-10">
{% if field.style.inline %}
{% for key, text in field.choices.items %}
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html b/rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html
index c0dbb989..3ed2874b 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/horizontal/label.html" %}
+ {% if field.label %}
+ <label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
+ {% endif %}
<div class="col-sm-10">
<select multiple class="form-control" name="{{ field.name }}">
{% for key, text in field.choices.items %}
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_radio.html b/rest_framework/templates/rest_framework/horizontal/fields/select_radio.html
index 0eeb9bc6..6e56afb5 100644
--- a/rest_framework/templates/rest_framework/fields/horizontal/select_radio.html
+++ b/rest_framework/templates/rest_framework/horizontal/fields/select_radio.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/horizontal/label.html" %}
+ {% if field.label %}
+ <label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
+ {% endif %}
<div class="col-sm-10">
{% if field.style.inline %}
{% for key, text in field.choices.items %}
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/textarea.html b/rest_framework/templates/rest_framework/horizontal/fields/textarea.html
new file mode 100644
index 00000000..ae263c48
--- /dev/null
+++ b/rest_framework/templates/rest_framework/horizontal/fields/textarea.html
@@ -0,0 +1,9 @@
+<div class="form-group">
+ {% if field.label %}
+ <label class="col-sm-2 control-label {% if field.style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
+ {% endif %}
+ <div class="col-sm-10">
+ <textarea name="{{ field.name }}" class="form-control" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.style.rows %}rows="{{ field.style.rows }}"{% endif %}>{% if field.value %}{{ field.value }}{% endif %}</textarea>
+ {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
+ </div>
+</div>
diff --git a/rest_framework/templates/rest_framework/horizontal/form.html b/rest_framework/templates/rest_framework/horizontal/form.html
new file mode 100644
index 00000000..7560d8a2
--- /dev/null
+++ b/rest_framework/templates/rest_framework/horizontal/form.html
@@ -0,0 +1,15 @@
+{% load rest_framework %}
+<form class="form-horizontal" role="form" action="." method="POST">
+ {% csrf_token %}
+ {% for field in form %}
+ {% if not field.read_only %}
+ {% render_field field template_pack=template_pack renderer=renderer %}
+ {% endif %}
+ {% endfor %}
+ <!-- form.non_field_errors -->
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <button type="submit" class="btn btn-default">Submit</button>
+ </div>
+ </div>
+</form>
diff --git a/rest_framework/templates/rest_framework/fields/inline/checkbox.html b/rest_framework/templates/rest_framework/inline/fields/checkbox.html
index 57fa5dc0..57fa5dc0 100644
--- a/rest_framework/templates/rest_framework/fields/inline/checkbox.html
+++ b/rest_framework/templates/rest_framework/inline/fields/checkbox.html
diff --git a/rest_framework/templates/rest_framework/fields/inline/fieldset.html b/rest_framework/templates/rest_framework/inline/fields/fieldset.html
index ba9f1835..ba9f1835 100644
--- a/rest_framework/templates/rest_framework/fields/inline/fieldset.html
+++ b/rest_framework/templates/rest_framework/inline/fields/fieldset.html
diff --git a/rest_framework/templates/rest_framework/inline/fields/input.html b/rest_framework/templates/rest_framework/inline/fields/input.html
new file mode 100644
index 00000000..bdf25ffe
--- /dev/null
+++ b/rest_framework/templates/rest_framework/inline/fields/input.html
@@ -0,0 +1,6 @@
+<div class="form-group">
+ {% if field.label %}
+ <label class="sr-only">{{ field.label }}</label>
+ {% endif %}
+ <input name="{{ field.name }}" type="{{ input_type }}" class="form-control" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %}>
+</div>
diff --git a/rest_framework/templates/rest_framework/fields/inline/select.html b/rest_framework/templates/rest_framework/inline/fields/select.html
index eebb91d2..730fcce6 100644
--- a/rest_framework/templates/rest_framework/fields/inline/select.html
+++ b/rest_framework/templates/rest_framework/inline/fields/select.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/inline/label.html" %}
+ {% if field.label %}
+ <label class="sr-only">{{ field.label }}</label>
+ {% endif %}
<select class="form-control" name="{{ field.name }}">
{% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option>
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_checkbox.html b/rest_framework/templates/rest_framework/inline/fields/select_checkbox.html
index b7561cd4..cca71d68 100644
--- a/rest_framework/templates/rest_framework/fields/inline/select_checkbox.html
+++ b/rest_framework/templates/rest_framework/inline/fields/select_checkbox.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/inline/label.html" %}
+ {% if field.label %}
+ <label class="sr-only">{{ field.label }}</label>
+ {% endif %}
{% for key, text in field.choices.items %}
<div class="checkbox">
<label>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_multiple.html b/rest_framework/templates/rest_framework/inline/fields/select_multiple.html
index 5f4166cd..3f9b2701 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/select_multiple.html
+++ b/rest_framework/templates/rest_framework/inline/fields/select_multiple.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/vertical/label.html" %}
+ {% if field.label %}
+ <label class="sr-only">{{ field.label }}</label>
+ {% endif %}
<select multiple class="form-control" name="{{ field.name }}">
{% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key in field.value %}selected{% endif %}>{{ text }}</option>
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_radio.html b/rest_framework/templates/rest_framework/inline/fields/select_radio.html
index 27927a62..3fffceac 100644
--- a/rest_framework/templates/rest_framework/fields/inline/select_radio.html
+++ b/rest_framework/templates/rest_framework/inline/fields/select_radio.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/inline/label.html" %}
+ {% if field.label %}
+ <label class="sr-only">{{ field.label }}</label>
+ {% endif %}
{% for key, text in field.choices.items %}
<div class="radio">
<label>
diff --git a/rest_framework/templates/rest_framework/inline/fields/textarea.html b/rest_framework/templates/rest_framework/inline/fields/textarea.html
new file mode 100644
index 00000000..bdf25ffe
--- /dev/null
+++ b/rest_framework/templates/rest_framework/inline/fields/textarea.html
@@ -0,0 +1,6 @@
+<div class="form-group">
+ {% if field.label %}
+ <label class="sr-only">{{ field.label }}</label>
+ {% endif %}
+ <input name="{{ field.name }}" type="{{ input_type }}" class="form-control" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %}>
+</div>
diff --git a/rest_framework/templates/rest_framework/inline/form.html b/rest_framework/templates/rest_framework/inline/form.html
new file mode 100644
index 00000000..b13d1661
--- /dev/null
+++ b/rest_framework/templates/rest_framework/inline/form.html
@@ -0,0 +1,11 @@
+{% load rest_framework %}
+<form class="form-inline" role="form" action="." method="POST">
+ {% csrf_token %}
+ {% for field in form %}
+ {% if not field.read_only %}
+ {% render_field field template_pack=template_pack renderer=renderer %}
+ {% endif %}
+ {% endfor %}
+ <!-- form.non_field_errors -->
+ <button type="submit" class="btn btn-default">Submit</button>
+</form>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/checkbox.html b/rest_framework/templates/rest_framework/vertical/fields/checkbox.html
index 9fd4cdaa..9fd4cdaa 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/checkbox.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/checkbox.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/fieldset.html b/rest_framework/templates/rest_framework/vertical/fields/fieldset.html
index 248fe904..248fe904 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/fieldset.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/fieldset.html
diff --git a/rest_framework/templates/rest_framework/vertical/fields/input.html b/rest_framework/templates/rest_framework/vertical/fields/input.html
new file mode 100644
index 00000000..10a576b2
--- /dev/null
+++ b/rest_framework/templates/rest_framework/vertical/fields/input.html
@@ -0,0 +1,7 @@
+<div class="form-group">
+ {% if field.label %}
+ <label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
+ {% endif %}
+ <input name="{{ field.name }}" type="{{ input_type }}" class="form-control" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.style.rows %}rows="{{ field.style.rows }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %}>
+ {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
+</div>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html b/rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html
index 6b99a834..6b99a834 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select.html b/rest_framework/templates/rest_framework/vertical/fields/select.html
index 1a651663..b0545f7e 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/select.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/select.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/vertical/label.html" %}
+ {% if field.label %}
+ <label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
+ {% endif %}
<select class="form-control" name="{{ field.name }}">
{% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html b/rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html
index 2e792e6a..c486b1b3 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/vertical/label.html" %}
+ {% if field.label %}
+ <label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
+ {% endif %}
{% if field.style.inline %}
<div>
{% for key, text in field.choices.items %}
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_multiple.html b/rest_framework/templates/rest_framework/vertical/fields/select_multiple.html
index 74e17f9f..ca63192e 100644
--- a/rest_framework/templates/rest_framework/fields/inline/select_multiple.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/select_multiple.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/inline/label.html" %}
+ {% if field.label %}
+ <label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
+ {% endif %}
<select multiple class="form-control" name="{{ field.name }}">
{% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key in field.value %}selected{% endif %}>{{ text }}</option>
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_radio.html b/rest_framework/templates/rest_framework/vertical/fields/select_radio.html
index 2aa0fe28..d7655b00 100644
--- a/rest_framework/templates/rest_framework/fields/vertical/select_radio.html
+++ b/rest_framework/templates/rest_framework/vertical/fields/select_radio.html
@@ -1,5 +1,7 @@
<div class="form-group">
- {% include "rest_framework/fields/vertical/label.html" %}
+ {% if field.label %}
+ <label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
+ {% endif %}
{% if field.style.inline %}
<div>
{% for key, text in field.choices.items %}
diff --git a/rest_framework/templates/rest_framework/vertical/fields/textarea.html b/rest_framework/templates/rest_framework/vertical/fields/textarea.html
new file mode 100644
index 00000000..8d951496
--- /dev/null
+++ b/rest_framework/templates/rest_framework/vertical/fields/textarea.html
@@ -0,0 +1,7 @@
+<div class="form-group">
+ {% if field.label %}
+ <label {% if field.style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
+ {% endif %}
+ <textarea name="{{ field.name }}" class="form-control" {% if field.style.placeholder %}placeholder="{{ field.style.placeholder }}"{% endif %} {% if field.style.rows %}rows="{{ field.style.rows }}"{% endif %}>{% if field.value %}{{ field.value }}{% endif %}</textarea>
+ {% if field.help_text %}<p class="help-block">{{ field.help_text }}</p>{% endif %}
+</div>
diff --git a/rest_framework/templates/rest_framework/vertical/form.html b/rest_framework/templates/rest_framework/vertical/form.html
new file mode 100644
index 00000000..fe908af0
--- /dev/null
+++ b/rest_framework/templates/rest_framework/vertical/form.html
@@ -0,0 +1,11 @@
+{% load rest_framework %}
+<form role="form" action="." method="POST">
+ {% csrf_token %}
+ {% for field in form %}
+ {% if not field.read_only %}
+ {% render_field field template_pack=template_pack renderer=renderer %}
+ {% endif %}
+ {% endfor %}
+ <!-- form.non_field_errors -->
+ <button type="submit" class="btn btn-default">Submit</button>
+</form>
diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py
index 49a4c338..c092d39f 100644
--- a/rest_framework/templatetags/rest_framework.py
+++ b/rest_framework/templatetags/rest_framework.py
@@ -32,8 +32,8 @@ class_re = re.compile(r'(?<=class=["\'])(.*)(?=["\'])')
# And the template tags themselves...
@register.simple_tag
-def render_field(field, layout=None, renderer=None):
- return renderer.render_field(field, layout)
+def render_field(field, template_pack=None, renderer=None):
+ return renderer.render_field(field, template_pack)
@register.simple_tag