diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py
index 4fb360609..5fae75f2e 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/templates/rest_framework/fields/inline/textarea.html b/rest_framework/templates/rest_framework/fields/inline/textarea.html
deleted file mode 100644
index a644ea382..000000000
--- a/rest_framework/templates/rest_framework/fields/inline/textarea.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
- {% if field.label %}
-
- {% endif %}
-
-
diff --git a/rest_framework/templates/rest_framework/form.html b/rest_framework/templates/rest_framework/form.html
deleted file mode 100644
index 162c56336..000000000
--- a/rest_framework/templates/rest_framework/form.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-{% load rest_framework %}
-
-
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/checkbox.html b/rest_framework/templates/rest_framework/horizontal/fields/checkbox.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/checkbox.html
rename to 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
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/fieldset.html
rename to rest_framework/templates/rest_framework/horizontal/fields/fieldset.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/input.html b/rest_framework/templates/rest_framework/horizontal/fields/input.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/input.html
rename to rest_framework/templates/rest_framework/horizontal/fields/input.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html b/rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html
rename to 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
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/select.html
rename to rest_framework/templates/rest_framework/horizontal/fields/select.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html b/rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html
rename to rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html b/rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html
rename to rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_radio.html b/rest_framework/templates/rest_framework/horizontal/fields/select_radio.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/select_radio.html
rename to rest_framework/templates/rest_framework/horizontal/fields/select_radio.html
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/textarea.html b/rest_framework/templates/rest_framework/horizontal/fields/textarea.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/horizontal/textarea.html
rename to rest_framework/templates/rest_framework/horizontal/fields/textarea.html
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 000000000..7560d8a26
--- /dev/null
+++ b/rest_framework/templates/rest_framework/horizontal/form.html
@@ -0,0 +1,15 @@
+{% load rest_framework %}
+
diff --git a/rest_framework/templates/rest_framework/fields/inline/checkbox.html b/rest_framework/templates/rest_framework/inline/fields/checkbox.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/checkbox.html
rename to 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
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/fieldset.html
rename to rest_framework/templates/rest_framework/inline/fields/fieldset.html
diff --git a/rest_framework/templates/rest_framework/fields/inline/input.html b/rest_framework/templates/rest_framework/inline/fields/input.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/input.html
rename to rest_framework/templates/rest_framework/inline/fields/input.html
diff --git a/rest_framework/templates/rest_framework/fields/inline/select.html b/rest_framework/templates/rest_framework/inline/fields/select.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/select.html
rename to rest_framework/templates/rest_framework/inline/fields/select.html
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_checkbox.html b/rest_framework/templates/rest_framework/inline/fields/select_checkbox.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/select_checkbox.html
rename to rest_framework/templates/rest_framework/inline/fields/select_checkbox.html
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_multiple.html b/rest_framework/templates/rest_framework/inline/fields/select_multiple.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/select_multiple.html
rename to rest_framework/templates/rest_framework/inline/fields/select_multiple.html
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_radio.html b/rest_framework/templates/rest_framework/inline/fields/select_radio.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/inline/select_radio.html
rename to rest_framework/templates/rest_framework/inline/fields/select_radio.html
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 000000000..bdf25ffe6
--- /dev/null
+++ b/rest_framework/templates/rest_framework/inline/fields/textarea.html
@@ -0,0 +1,6 @@
+
+ {% if field.label %}
+
+ {% endif %}
+
+
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 000000000..b13d16614
--- /dev/null
+++ b/rest_framework/templates/rest_framework/inline/form.html
@@ -0,0 +1,11 @@
+{% load rest_framework %}
+
diff --git a/rest_framework/templates/rest_framework/fields/vertical/checkbox.html b/rest_framework/templates/rest_framework/vertical/fields/checkbox.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/checkbox.html
rename to 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
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/fieldset.html
rename to rest_framework/templates/rest_framework/vertical/fields/fieldset.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/input.html b/rest_framework/templates/rest_framework/vertical/fields/input.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/input.html
rename to rest_framework/templates/rest_framework/vertical/fields/input.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html b/rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html
rename to 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
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/select.html
rename to rest_framework/templates/rest_framework/vertical/fields/select.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html b/rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html
rename to rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_multiple.html b/rest_framework/templates/rest_framework/vertical/fields/select_multiple.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/select_multiple.html
rename to rest_framework/templates/rest_framework/vertical/fields/select_multiple.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_radio.html b/rest_framework/templates/rest_framework/vertical/fields/select_radio.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/select_radio.html
rename to rest_framework/templates/rest_framework/vertical/fields/select_radio.html
diff --git a/rest_framework/templates/rest_framework/fields/vertical/textarea.html b/rest_framework/templates/rest_framework/vertical/fields/textarea.html
similarity index 100%
rename from rest_framework/templates/rest_framework/fields/vertical/textarea.html
rename to rest_framework/templates/rest_framework/vertical/fields/textarea.html
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 000000000..fe908af02
--- /dev/null
+++ b/rest_framework/templates/rest_framework/vertical/form.html
@@ -0,0 +1,11 @@
+{% load rest_framework %}
+
diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py
index 49a4c3389..c092d39f6 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