Skip to content

Instantly share code, notes, and snippets.

@jeffkistler
Created March 9, 2011 20:39
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffkistler/862959 to your computer and use it in GitHub Desktop.
Save jeffkistler/862959 to your computer and use it in GitHub Desktop.
A generic Django authentication form template.
{% comment %}
Include this template from your site base template like so:
{% if user.is_anonymous %}
{% include "login_form.html" %}
{% endif %}
{% endcomment %}
{% load i18n %}
<form method="post" action="{% url django.contrib.auth.views.login %}">
{{ auth_form.non_field_errors }}
<p>
{{ auth_form.username.errors }}
<label for="id_username">{% trans "Username" %}:</label> <input type="text" name="username" id="id_username">
</p>
<p>
{{ auth_form.password.errors }}
<label for="id_password">{% trans "Password" %}:</label> <input type="text" name="password" id="id_password">
</p>
<p>
<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
<input type="submit" value="{% trans "Log in" %}">
<input type="hidden" name="next" value="{{ next }}">
</p>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment