1

I am trying to use Crispy forms with Django-userena to make it look better but when ever I put the Crispy form tags in it duplicates the form,

My code is as followed:

{% extends 'userena/base_userena.html' %}
{% load i18n %}
{% load url from future %}
{% load crispy_forms_tags %}
{% block title %}{% trans "Signin" %}{% endblock %}
{% block content %}
<form action="" method="post" class="formholder">
  {% csrf_token %}
  {{ form|crispy }}
  <fieldset>
    <legend>{% trans "Signin" %}</legend>
    {{ form.non_field_errors }}
    {% for field in form %}
    {{ field.errors }}
    {% comment %} Displaying checkboxes differently {% endcomment %}
    {% if field.name == 'remember_me' %}
    <p class="checkbox">
    <label for="id_{{ field.name }}">{{ field }} {{ field.label }}</label>
    </p>
    {% else %}
    <p>
    {{ field.label_tag }}
    {{ field }}
    </p>
    {% endif %}
    {% endfor %}
  </fieldset>
  <input type="submit" value="{% trans "Signin" %}" />
  <p class="forgot-password"><a href="{% url 'userena_password_reset' %}" title="{% trans 'Forgot your password?' %}">{% trans "Forgot your password?" %}</a></p>
  {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
</form>
{% endblock %}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Blezx
  • 614
  • 2
  • 6
  • 19

1 Answers1

0

Solution by OP.

The problem was that the, {{ form|crispy }} was actually creating the form in the form.py file all I had to do was remove all the other from tags and just keep the {{ form|crispy }}

Here is what it looks like:

{% extends 'userena/base_userena.html' %}
{% load i18n %}
{% load url from future %}
{% block title %}{% trans "Signin" %}{% endblock %}
{% block content %}
{% load crispy_forms_tags %}
<form action="" method="post" class="formholder">
  {% csrf_token %}
  <fieldset>
    <legend>{% trans "Signin" %}</legend>
      {{ form|crispy }}
  </fieldset>
  <input type="submit" value="{% trans "Signin" %}" />
  <p class="forgot-password"><a href="{% url 'userena_password_reset' %}" title="{% trans 'Forgot your password?' %}">{% trans "Forgot your password?" %}</a></p>
  {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
</div>
</form>
{% endblock %}
Cœur
  • 37,241
  • 25
  • 195
  • 267