Skip to content

Instantly share code, notes, and snippets.

@whosaysni
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whosaysni/11100003 to your computer and use it in GitHub Desktop.
Save whosaysni/11100003 to your computer and use it in GitHub Desktop.
Template-only MetroUI-widgets-in-Django
<div class="container padding10">
<h1>Add user</h1>
<div class="padding10">
<form method="POST" action="{% url 'user_add' %}">
{% csrf_token %}
<fieldset>
{% with field=form.is_superuser type='switch' %}{% include "share/form_field.html" %}{% endwith %}
{% with field=form.is_active type='switch' %}{% include "share/form_field.html" %}{% endwith %}
{% with field=form.username type='text' %}{% include "share/form_field.html" %}{% endwith %}
{% with field=form.password type='password' %}{% include "share/form_field.html" %}{% endwith %}
{% with field=form.email type='text' %}{% include "share/form_field.html" %}{% endwith %}
{% with field=form.first_name type='text' %}{% include "share/form_field.html" %}{% endwith %}
{% with field=form.last_name type='text' %}{% include "share/form_field.html" %}{% endwith %}
</fieldset>
<div class="button-group">
<input type="submit" value="Add" />
</div>
</form>
</div>
</div>
{{ field.label_tag }}
<p class="tertiary-text-secondary">
{{ field.help_text }}
</p>
<div>
{% with field_type=type|default:"" %}
<div class="input-control {{ field_type }} {{ field_size|default:'size3' }}
{% if field.errors %}error-state{% endif %}" data-role="input-control">
{% ifequal field_type "" %}
{{ field }}
{% endifequal %}
{% ifequal field_type "text" %}
{{ field }}
<button type="button" class="btn-clear"></button>
{% endifequal %}
{% ifequal field_type "password" %}
{{ field }}
<button type="button" class="btn-reveal"></button>
{% endifequal %}
{% ifequal field_type "switch" %}
<label>
{{ field }}
<span class="check"></span>
</label>
{% endifequal %}
<span class="tertiary-text text-alert">
{{ field.errors.as_text }}
</span>
</div>
{% endwith %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment