Skip to content

Instantly share code, notes, and snippets.

@starsinmypockets
Last active December 11, 2015 05:59
Show Gist options
  • Save starsinmypockets/4556367 to your computer and use it in GitHub Desktop.
Save starsinmypockets/4556367 to your computer and use it in GitHub Desktop.
Basic example of formulation implementation for django modelform
{% block basic %}
{% if not nolabel %}{{ field.label_tag }}{% endif %}
<input type="{{ field_type|default:"text" }}" name="{{ field.html_name }}" id="{{ field.auto_id }}" value="{{ field.value|default:"" }}" class="{{ field.css_classes }} {{ extra_classes }}" />
{{ field.help_text }}
{% endblock %}
{% load formullation %}
<form id = "myform" ...>
{% form "myfieldtemplate.html" %}
{% for formfield in fields %}
{% field "basic" formfield %} {# <---- 'field' calls formulation tag, "basic" defines block, formfield passes the field to render #}
{% endfor %}
</form>
def get_form(request):
form = MyModelForm()
return render_to_response('myform.html', {'form' : form,}, RequestContext(request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment