From cc1c4232554153ac6a24b6b4f89ecaac80b28bfd Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 15 Oct 2014 11:12:34 +0100 Subject: Reorganize to use template_pack in form rendering --- rest_framework/renderers.py | 15 +++------- .../rest_framework/fields/horizontal/checkbox.html | 10 ------- .../rest_framework/fields/horizontal/fieldset.html | 11 -------- .../rest_framework/fields/horizontal/input.html | 9 ------ .../fields/horizontal/list_fieldset.html | 13 --------- .../rest_framework/fields/horizontal/select.html | 12 -------- .../fields/horizontal/select_checkbox.html | 24 ---------------- .../fields/horizontal/select_multiple.html | 12 -------- .../fields/horizontal/select_radio.html | 24 ---------------- .../rest_framework/fields/horizontal/textarea.html | 9 ------ .../rest_framework/fields/inline/checkbox.html | 6 ---- .../rest_framework/fields/inline/fieldset.html | 4 --- .../rest_framework/fields/inline/input.html | 6 ---- .../rest_framework/fields/inline/select.html | 10 ------- .../fields/inline/select_checkbox.html | 13 --------- .../fields/inline/select_multiple.html | 10 ------- .../rest_framework/fields/inline/select_radio.html | 13 --------- .../rest_framework/fields/inline/textarea.html | 6 ---- .../rest_framework/fields/vertical/checkbox.html | 6 ---- .../rest_framework/fields/vertical/fieldset.html | 7 ----- .../rest_framework/fields/vertical/input.html | 7 ----- .../fields/vertical/list_fieldset.html | 7 ----- .../rest_framework/fields/vertical/select.html | 10 ------- .../fields/vertical/select_checkbox.html | 24 ---------------- .../fields/vertical/select_multiple.html | 10 ------- .../fields/vertical/select_radio.html | 24 ---------------- .../rest_framework/fields/vertical/textarea.html | 7 ----- rest_framework/templates/rest_framework/form.html | 33 ---------------------- .../rest_framework/horizontal/fields/checkbox.html | 10 +++++++ .../rest_framework/horizontal/fields/fieldset.html | 11 ++++++++ .../rest_framework/horizontal/fields/input.html | 9 ++++++ .../horizontal/fields/list_fieldset.html | 13 +++++++++ .../rest_framework/horizontal/fields/select.html | 12 ++++++++ .../horizontal/fields/select_checkbox.html | 24 ++++++++++++++++ .../horizontal/fields/select_multiple.html | 12 ++++++++ .../horizontal/fields/select_radio.html | 24 ++++++++++++++++ .../rest_framework/horizontal/fields/textarea.html | 9 ++++++ .../templates/rest_framework/horizontal/form.html | 15 ++++++++++ .../rest_framework/inline/fields/checkbox.html | 6 ++++ .../rest_framework/inline/fields/fieldset.html | 4 +++ .../rest_framework/inline/fields/input.html | 6 ++++ .../rest_framework/inline/fields/select.html | 10 +++++++ .../inline/fields/select_checkbox.html | 13 +++++++++ .../inline/fields/select_multiple.html | 10 +++++++ .../rest_framework/inline/fields/select_radio.html | 13 +++++++++ .../rest_framework/inline/fields/textarea.html | 6 ++++ .../templates/rest_framework/inline/form.html | 11 ++++++++ .../rest_framework/vertical/fields/checkbox.html | 6 ++++ .../rest_framework/vertical/fields/fieldset.html | 7 +++++ .../rest_framework/vertical/fields/input.html | 7 +++++ .../vertical/fields/list_fieldset.html | 7 +++++ .../rest_framework/vertical/fields/select.html | 10 +++++++ .../vertical/fields/select_checkbox.html | 24 ++++++++++++++++ .../vertical/fields/select_multiple.html | 10 +++++++ .../vertical/fields/select_radio.html | 24 ++++++++++++++++ .../rest_framework/vertical/fields/textarea.html | 7 +++++ .../templates/rest_framework/vertical/form.html | 11 ++++++++ rest_framework/templatetags/rest_framework.py | 4 +-- 58 files changed, 337 insertions(+), 340 deletions(-) delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/checkbox.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/fieldset.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/input.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/select.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/select_radio.html delete mode 100644 rest_framework/templates/rest_framework/fields/horizontal/textarea.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/checkbox.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/fieldset.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/input.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/select.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/select_checkbox.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/select_multiple.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/select_radio.html delete mode 100644 rest_framework/templates/rest_framework/fields/inline/textarea.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/checkbox.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/fieldset.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/input.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/select.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/select_multiple.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/select_radio.html delete mode 100644 rest_framework/templates/rest_framework/fields/vertical/textarea.html delete mode 100644 rest_framework/templates/rest_framework/form.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/checkbox.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/fieldset.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/input.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/select.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/select_radio.html create mode 100644 rest_framework/templates/rest_framework/horizontal/fields/textarea.html create mode 100644 rest_framework/templates/rest_framework/horizontal/form.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/checkbox.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/fieldset.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/input.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/select.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/select_checkbox.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/select_multiple.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/select_radio.html create mode 100644 rest_framework/templates/rest_framework/inline/fields/textarea.html create mode 100644 rest_framework/templates/rest_framework/inline/form.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/checkbox.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/fieldset.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/input.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/select.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/select_multiple.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/select_radio.html create mode 100644 rest_framework/templates/rest_framework/vertical/fields/textarea.html create mode 100644 rest_framework/templates/rest_framework/vertical/form.html (limited to 'rest_framework') 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/templates/rest_framework/fields/horizontal/checkbox.html b/rest_framework/templates/rest_framework/fields/horizontal/checkbox.html deleted file mode 100644 index ee3bf936..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/checkbox.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
-
- -
-
-
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/fieldset.html b/rest_framework/templates/rest_framework/fields/horizontal/fieldset.html deleted file mode 100644 index ff93c6ba..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/fieldset.html +++ /dev/null @@ -1,11 +0,0 @@ -{% load rest_framework %} -
- {% if field.label %} -
- {{ field.label }} -
- {% endif %} - {% for nested_field in field %} - {% render_field nested_field layout=layout renderer=renderer %} - {% endfor %} -
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 6621c7e6..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/input.html +++ /dev/null @@ -1,9 +0,0 @@ -
- {% if field.label %} - - {% endif %} -
- - {% if field.help_text %}

{{ field.help_text }}

{% endif %} -
-
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html b/rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html deleted file mode 100644 index 68c75d4f..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/list_fieldset.html +++ /dev/null @@ -1,13 +0,0 @@ -{% load rest_framework %} -
- {% if field.label %} -
- {{ field.label }} -
- {% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select.html b/rest_framework/templates/rest_framework/fields/horizontal/select.html deleted file mode 100644 index eaa6d575..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/select.html +++ /dev/null @@ -1,12 +0,0 @@ -
- {% if field.label %} - - {% endif %} -
- -
-
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html b/rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html deleted file mode 100644 index ff3fab57..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/select_checkbox.html +++ /dev/null @@ -1,24 +0,0 @@ -
- {% if field.label %} - - {% endif %} -
- {% if field.style.inline %} - {% for key, text in field.choices.items %} - - {% endfor %} - {% else %} - {% for key, text in field.choices.items %} -
- -
- {% endfor %} - {% endif %} -
-
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html b/rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html deleted file mode 100644 index 3ed2874b..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/select_multiple.html +++ /dev/null @@ -1,12 +0,0 @@ -
- {% if field.label %} - - {% endif %} -
- -
-
diff --git a/rest_framework/templates/rest_framework/fields/horizontal/select_radio.html b/rest_framework/templates/rest_framework/fields/horizontal/select_radio.html deleted file mode 100644 index 6e56afb5..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/select_radio.html +++ /dev/null @@ -1,24 +0,0 @@ -
- {% if field.label %} - - {% endif %} -
- {% if field.style.inline %} - {% for key, text in field.choices.items %} - - {% endfor %} - {% else %} - {% for key, text in field.choices.items %} -
- -
- {% endfor %} - {% 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 ae263c48..00000000 --- a/rest_framework/templates/rest_framework/fields/horizontal/textarea.html +++ /dev/null @@ -1,9 +0,0 @@ -
- {% if field.label %} - - {% endif %} -
- - {% if field.help_text %}

{{ field.help_text }}

{% endif %} -
-
diff --git a/rest_framework/templates/rest_framework/fields/inline/checkbox.html b/rest_framework/templates/rest_framework/fields/inline/checkbox.html deleted file mode 100644 index 57fa5dc0..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/checkbox.html +++ /dev/null @@ -1,6 +0,0 @@ -
- -
diff --git a/rest_framework/templates/rest_framework/fields/inline/fieldset.html b/rest_framework/templates/rest_framework/fields/inline/fieldset.html deleted file mode 100644 index ba9f1835..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/fieldset.html +++ /dev/null @@ -1,4 +0,0 @@ -{% load rest_framework %} -{% for nested_field in field %} - {% render_field nested_field layout=layout renderer=renderer %} -{% endfor %} 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 bdf25ffe..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/input.html +++ /dev/null @@ -1,6 +0,0 @@ -
- {% if field.label %} - - {% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/inline/select.html b/rest_framework/templates/rest_framework/fields/inline/select.html deleted file mode 100644 index 730fcce6..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/select.html +++ /dev/null @@ -1,10 +0,0 @@ -
- {% if field.label %} - - {% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_checkbox.html b/rest_framework/templates/rest_framework/fields/inline/select_checkbox.html deleted file mode 100644 index cca71d68..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/select_checkbox.html +++ /dev/null @@ -1,13 +0,0 @@ -
- {% if field.label %} - - {% endif %} - {% for key, text in field.choices.items %} -
- -
- {% endfor %} -
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_multiple.html b/rest_framework/templates/rest_framework/fields/inline/select_multiple.html deleted file mode 100644 index 3f9b2701..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/select_multiple.html +++ /dev/null @@ -1,10 +0,0 @@ -
- {% if field.label %} - - {% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/inline/select_radio.html b/rest_framework/templates/rest_framework/fields/inline/select_radio.html deleted file mode 100644 index 3fffceac..00000000 --- a/rest_framework/templates/rest_framework/fields/inline/select_radio.html +++ /dev/null @@ -1,13 +0,0 @@ -
- {% if field.label %} - - {% endif %} - {% for key, text in field.choices.items %} -
- -
- {% endfor %} -
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 a644ea38..00000000 --- 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/fields/vertical/checkbox.html b/rest_framework/templates/rest_framework/fields/vertical/checkbox.html deleted file mode 100644 index 9fd4cdaa..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/checkbox.html +++ /dev/null @@ -1,6 +0,0 @@ -
- -
diff --git a/rest_framework/templates/rest_framework/fields/vertical/fieldset.html b/rest_framework/templates/rest_framework/fields/vertical/fieldset.html deleted file mode 100644 index 248fe904..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/fieldset.html +++ /dev/null @@ -1,7 +0,0 @@ -{% load rest_framework %} -
- {% if field.label %}{{ field.label }}{% endif %} - {% for nested_field in field %} - {% render_field nested_field layout=layout renderer=renderer %} - {% endfor %} -
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 10a576b2..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/input.html +++ /dev/null @@ -1,7 +0,0 @@ -
- {% if field.label %} - - {% endif %} - - {% if field.help_text %}

{{ field.help_text }}

{% endif %} -
diff --git a/rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html b/rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html deleted file mode 100644 index 6b99a834..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/list_fieldset.html +++ /dev/null @@ -1,7 +0,0 @@ -
- {% if field.label %}{{ field.label }}{% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select.html b/rest_framework/templates/rest_framework/fields/vertical/select.html deleted file mode 100644 index b0545f7e..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/select.html +++ /dev/null @@ -1,10 +0,0 @@ -
- {% if field.label %} - - {% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html b/rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html deleted file mode 100644 index c486b1b3..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/select_checkbox.html +++ /dev/null @@ -1,24 +0,0 @@ -
- {% if field.label %} - - {% endif %} - {% if field.style.inline %} -
- {% for key, text in field.choices.items %} - - {% endfor %} -
- {% else %} - {% for key, text in field.choices.items %} -
- -
- {% endfor %} - {% endif %} -
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_multiple.html b/rest_framework/templates/rest_framework/fields/vertical/select_multiple.html deleted file mode 100644 index ca63192e..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/select_multiple.html +++ /dev/null @@ -1,10 +0,0 @@ -
- {% if field.label %} - - {% endif %} - -
diff --git a/rest_framework/templates/rest_framework/fields/vertical/select_radio.html b/rest_framework/templates/rest_framework/fields/vertical/select_radio.html deleted file mode 100644 index d7655b00..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/select_radio.html +++ /dev/null @@ -1,24 +0,0 @@ -
- {% if field.label %} - - {% endif %} - {% if field.style.inline %} -
- {% for key, text in field.choices.items %} - - {% endfor %} -
- {% else %} - {% for key, text in field.choices.items %} -
- -
- {% endfor %} - {% 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 8d951496..00000000 --- a/rest_framework/templates/rest_framework/fields/vertical/textarea.html +++ /dev/null @@ -1,7 +0,0 @@ -
- {% if field.label %} - - {% endif %} - - {% if field.help_text %}

{{ field.help_text }}

{% endif %} -
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 @@ - - -{% load rest_framework %} -
- {% csrf_token %} - {% for field in form %} - {% if not field.read_only %} - {% render_field field layout=layout renderer=renderer %} - {% endif %} - {% endfor %} - - {% if layout == "horizontal" %} -
-
- -
-
- {% else %} - - {% endif %} -
- diff --git a/rest_framework/templates/rest_framework/horizontal/fields/checkbox.html b/rest_framework/templates/rest_framework/horizontal/fields/checkbox.html new file mode 100644 index 00000000..ee3bf936 --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/checkbox.html @@ -0,0 +1,10 @@ +
+
+
+ +
+
+
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/fieldset.html b/rest_framework/templates/rest_framework/horizontal/fields/fieldset.html new file mode 100644 index 00000000..ff93c6ba --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/fieldset.html @@ -0,0 +1,11 @@ +{% load rest_framework %} +
+ {% if field.label %} +
+ {{ field.label }} +
+ {% endif %} + {% for nested_field in field %} + {% render_field nested_field layout=layout renderer=renderer %} + {% endfor %} +
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 @@ +
+ {% if field.label %} + + {% endif %} +
+ + {% if field.help_text %}

{{ field.help_text }}

{% endif %} +
+
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html b/rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html new file mode 100644 index 00000000..68c75d4f --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/list_fieldset.html @@ -0,0 +1,13 @@ +{% load rest_framework %} +
+ {% if field.label %} +
+ {{ field.label }} +
+ {% endif %} + +
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/select.html b/rest_framework/templates/rest_framework/horizontal/fields/select.html new file mode 100644 index 00000000..eaa6d575 --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/select.html @@ -0,0 +1,12 @@ +
+ {% if field.label %} + + {% endif %} +
+ +
+
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html b/rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html new file mode 100644 index 00000000..ff3fab57 --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/select_checkbox.html @@ -0,0 +1,24 @@ +
+ {% if field.label %} + + {% endif %} +
+ {% if field.style.inline %} + {% for key, text in field.choices.items %} + + {% endfor %} + {% else %} + {% for key, text in field.choices.items %} +
+ +
+ {% endfor %} + {% endif %} +
+
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html b/rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html new file mode 100644 index 00000000..3ed2874b --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/select_multiple.html @@ -0,0 +1,12 @@ +
+ {% if field.label %} + + {% endif %} +
+ +
+
diff --git a/rest_framework/templates/rest_framework/horizontal/fields/select_radio.html b/rest_framework/templates/rest_framework/horizontal/fields/select_radio.html new file mode 100644 index 00000000..6e56afb5 --- /dev/null +++ b/rest_framework/templates/rest_framework/horizontal/fields/select_radio.html @@ -0,0 +1,24 @@ +
+ {% if field.label %} + + {% endif %} +
+ {% if field.style.inline %} + {% for key, text in field.choices.items %} + + {% endfor %} + {% else %} + {% for key, text in field.choices.items %} +
+ +
+ {% endfor %} + {% endif %} +
+
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 @@ +
+ {% if field.label %} + + {% endif %} +
+ + {% if field.help_text %}

{{ field.help_text }}

{% endif %} +
+
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 %} +
+ {% csrf_token %} + {% for field in form %} + {% if not field.read_only %} + {% render_field field template_pack=template_pack renderer=renderer %} + {% endif %} + {% endfor %} + +
+
+ +
+
+
diff --git a/rest_framework/templates/rest_framework/inline/fields/checkbox.html b/rest_framework/templates/rest_framework/inline/fields/checkbox.html new file mode 100644 index 00000000..57fa5dc0 --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/fields/checkbox.html @@ -0,0 +1,6 @@ +
+ +
diff --git a/rest_framework/templates/rest_framework/inline/fields/fieldset.html b/rest_framework/templates/rest_framework/inline/fields/fieldset.html new file mode 100644 index 00000000..ba9f1835 --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/fields/fieldset.html @@ -0,0 +1,4 @@ +{% load rest_framework %} +{% for nested_field in field %} + {% render_field nested_field layout=layout renderer=renderer %} +{% endfor %} 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 @@ +
+ {% if field.label %} + + {% endif %} + +
diff --git a/rest_framework/templates/rest_framework/inline/fields/select.html b/rest_framework/templates/rest_framework/inline/fields/select.html new file mode 100644 index 00000000..730fcce6 --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/fields/select.html @@ -0,0 +1,10 @@ +
+ {% if field.label %} + + {% endif %} + +
diff --git a/rest_framework/templates/rest_framework/inline/fields/select_checkbox.html b/rest_framework/templates/rest_framework/inline/fields/select_checkbox.html new file mode 100644 index 00000000..cca71d68 --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/fields/select_checkbox.html @@ -0,0 +1,13 @@ +
+ {% if field.label %} + + {% endif %} + {% for key, text in field.choices.items %} +
+ +
+ {% endfor %} +
diff --git a/rest_framework/templates/rest_framework/inline/fields/select_multiple.html b/rest_framework/templates/rest_framework/inline/fields/select_multiple.html new file mode 100644 index 00000000..3f9b2701 --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/fields/select_multiple.html @@ -0,0 +1,10 @@ +
+ {% if field.label %} + + {% endif %} + +
diff --git a/rest_framework/templates/rest_framework/inline/fields/select_radio.html b/rest_framework/templates/rest_framework/inline/fields/select_radio.html new file mode 100644 index 00000000..3fffceac --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/fields/select_radio.html @@ -0,0 +1,13 @@ +
+ {% if field.label %} + + {% endif %} + {% for key, text in field.choices.items %} +
+ +
+ {% endfor %} +
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 @@ +
+ {% 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 00000000..b13d1661 --- /dev/null +++ b/rest_framework/templates/rest_framework/inline/form.html @@ -0,0 +1,11 @@ +{% load rest_framework %} +
+ {% csrf_token %} + {% for field in form %} + {% if not field.read_only %} + {% render_field field template_pack=template_pack renderer=renderer %} + {% endif %} + {% endfor %} + + +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/checkbox.html b/rest_framework/templates/rest_framework/vertical/fields/checkbox.html new file mode 100644 index 00000000..9fd4cdaa --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/checkbox.html @@ -0,0 +1,6 @@ +
+ +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/fieldset.html b/rest_framework/templates/rest_framework/vertical/fields/fieldset.html new file mode 100644 index 00000000..248fe904 --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/fieldset.html @@ -0,0 +1,7 @@ +{% load rest_framework %} +
+ {% if field.label %}{{ field.label }}{% endif %} + {% for nested_field in field %} + {% render_field nested_field layout=layout renderer=renderer %} + {% endfor %} +
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 @@ +
+ {% if field.label %} + + {% endif %} + + {% if field.help_text %}

{{ field.help_text }}

{% endif %} +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html b/rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html new file mode 100644 index 00000000..6b99a834 --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/list_fieldset.html @@ -0,0 +1,7 @@ +
+ {% if field.label %}{{ field.label }}{% endif %} + +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/select.html b/rest_framework/templates/rest_framework/vertical/fields/select.html new file mode 100644 index 00000000..b0545f7e --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/select.html @@ -0,0 +1,10 @@ +
+ {% if field.label %} + + {% endif %} + +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html b/rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html new file mode 100644 index 00000000..c486b1b3 --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/select_checkbox.html @@ -0,0 +1,24 @@ +
+ {% if field.label %} + + {% endif %} + {% if field.style.inline %} +
+ {% for key, text in field.choices.items %} + + {% endfor %} +
+ {% else %} + {% for key, text in field.choices.items %} +
+ +
+ {% endfor %} + {% endif %} +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/select_multiple.html b/rest_framework/templates/rest_framework/vertical/fields/select_multiple.html new file mode 100644 index 00000000..ca63192e --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/select_multiple.html @@ -0,0 +1,10 @@ +
+ {% if field.label %} + + {% endif %} + +
diff --git a/rest_framework/templates/rest_framework/vertical/fields/select_radio.html b/rest_framework/templates/rest_framework/vertical/fields/select_radio.html new file mode 100644 index 00000000..d7655b00 --- /dev/null +++ b/rest_framework/templates/rest_framework/vertical/fields/select_radio.html @@ -0,0 +1,24 @@ +
+ {% if field.label %} + + {% endif %} + {% if field.style.inline %} +
+ {% for key, text in field.choices.items %} + + {% endfor %} +
+ {% else %} + {% for key, text in field.choices.items %} +
+ +
+ {% endfor %} + {% endif %} +
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 @@ +
+ {% if field.label %} + + {% endif %} + + {% if field.help_text %}

{{ field.help_text }}

{% endif %} +
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 %} +
+ {% csrf_token %} + {% for field in form %} + {% if not field.read_only %} + {% render_field field template_pack=template_pack renderer=renderer %} + {% endif %} + {% endfor %} + + +
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 -- cgit v1.2.3