Python Forum
Display google recpatcha at the end of the form django-allauth app
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display google recpatcha at the end of the form django-allauth app
#1
I am creating a signup form using django(1.10) allauth app. I have installed django-recaptcha app from - https://github.com/praekelt/django-recaptcha

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.

Forms.py

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'})
signup.html
{% 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>
</form>

{% 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.
Reply
#2
What password field?  It doesn't look like you have any.
Reply
#3
I am using django-allauth app. It has 4 fields.(Username, email, password1, password2) If account_username_required is false in settings.py then it won't show.

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  trying to display custom error message on form mp3909 0 1,558 Nov-19-2020, 06:35 PM
Last Post: mp3909
  Django send email - email form Remek953 2 2,247 Sep-18-2020, 07:07 AM
Last Post: Remek953
  How to send notifications to gmail from contact form using Django and pushbullet Justchse 0 1,840 Sep-01-2020, 01:19 PM
Last Post: Justchse
  Django admin form with parent child tmmaersk 0 1,836 Apr-02-2020, 06:42 AM
Last Post: tmmaersk
  display local images on django website mp3909 2 6,247 Apr-01-2020, 11:18 AM
Last Post: mp3909
  Send email to gmail after user fill up contact form and getting django database updat Man_from_India 0 2,070 Jan-22-2020, 03:59 PM
Last Post: Man_from_India
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,246 Jun-30-2019, 12:21 AM
Last Post: scidam
  Django - Retrieve form data justantest 0 2,814 May-23-2019, 11:47 AM
Last Post: justantest
  How to add one more similar form by clicking on the current one using JS? Django m0ntecr1st0 0 1,785 Mar-01-2019, 01:02 PM
Last Post: m0ntecr1st0
  ImportError: No module named django.core.exceptions in google app engine timtinan37 4 4,911 Jun-18-2018, 01:34 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020