Python Forum

Full Version: Display google recpatcha at the end of the form django-allauth app
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am creating a signup form using django(1.10) allauth app. I have installed django-recaptcha app from -

The captcha is working but it is showing after the field 'Organisation' as I am calling the module after 'Organisation' field. Is there any way so that the field displays at the end after password field.

from django import forms
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Field
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteField
from phonenumber_field.formfields  import PhoneNumberField
from . import models
from captcha.fields import ReCaptchaField

class SignUpForm(forms.Form):
    first_name = forms.CharField(max_length=30)
    last_name = forms.CharField(max_length=30)
    phone_number = PhoneNumberField(label=_("Phone (Please state your country code eg. +44)"))
    organisation = forms.CharField(max_length=50)
    captcha = ReCaptchaField(attrs={'theme' : 'clean'})
{% extends "account/base.html" %}

{% load i18n crispy_forms_tags %}

{% block head_title %}{% trans "Signup" %}{% endblock %}

{% block content %}
<h1>{% trans "Sign Up" %}</h1>

<p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p>

<form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}">
  {% csrf_token %}
  {{ form|crispy }}
  {% if redirect_field_value %}
  <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
  {% endif %}

  <button class="btn btn-success" type="submit">{% trans "Sign Up" %} <span class="fa fa-chevron-right"></span></button>

{% endblock %}
The captcha needs to put after 'password again' field. Do I need to create sub class or something like that?

Any help is highly appreciated.
What password field?  It doesn't look like you have any.
I am using django-allauth app. It has 4 fields.(Username, email, password1, password2) If account_username_required is false in then it won't show.

So these fields load after the custom fields which I have defined under signupform class. That's the problem.