9

For the sake of consistency I want to use crispy with my login form. I'm using 'django.contrib.auth.views.login' and I'm only coding the template.

The problem is {% crispy form %} doesn’t output submit button nor "next" hidden field.

Is there any way to create FormHelper outside of forms.py ( it's in contrib.auth so I would need to try to extend AuthenticationForm or something like it) an then use it in the template without modifying views.py(also in contrib.auth)

If it would require any ninjitsu with extending classes etc. I will go with pure HTML but if there is a simple way to include 'external' FormHelper on the template level i would regret not asking

Cœur
  • 37,241
  • 25
  • 195
  • 267
Lord_JABA
  • 2,545
  • 7
  • 31
  • 58

1 Answers1

5

I'm not sure why do you need to use {% crispy form %} and not just the crispy filter. I'm using crispy in my login form, overriding the template from django.contrib.auth, this way:

{% load crispy_forms_tags %}

{% block body %}

<form method="post" action="" class="form-signin">{% csrf_token %}
    {{ form|crispy }}
    <div>
    <button type="submit" class="btn btn-primary">{% trans "Log in" %}</button>
    </div>
</form>

{% endblock %}
jantoniomartin
  • 215
  • 3
  • 9
  • 1
    One may not want to simply crispy the entire form -- for example, since I handle my errors separately, I do not want them displayed in the form. – Mala Apr 08 '14 at 04:45