Is it possible to use django-crispy-form FormHelper without changing the Form class

For consistency, I want to use a crispy shape with my entry form. I use 'django.contrib.auth.views.login' and I only encode the template.

The problem is that {% crispy form %} does not display the submit button or the "next" hidden field.

Is there a way to create a FormHelper outside of forms.py (this is in contrib.auth, so I need to try to extend the AuthenticationForm or something like this) and then use it in the template without changing views.py (also in contrib.auth)

If this requires any ninjitsu with expandable classes, etc., I will go with pure HTML, but if there is an easy way to enable the "external" FormHelper at the template level, I would regret not asking

+7
django django-forms django-templates django-authentication django-crispy-forms
source share
1 answer

I'm not sure why you should use the {% crispy form %} , not just the crispy filter. I use crunchy in my login form, overriding the template from django.contrib.auth, like this:

 {% 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 %} 
+5
source share

All Articles