Last active
December 11, 2015 05:59
-
-
Save starsinmypockets/4556367 to your computer and use it in GitHub Desktop.
Basic example of formulation implementation for django modelform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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