Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6155643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:28:13+00:00 2026-05-23T20:28:13+00:00

Here is my situation. I have a web page for users to create their

  • 0

Here is my situation. I have a web page for users to create their own accounts. On this page, there’s reCaptcha to prevent bots. Onece a user click on “Submit”, the reCaptcha validation is performed, prior to constructing the corresponding form, in the corresponding view. Let’s say the user’s input failed the reCaptcha validation. How should I prompt this error back to the user? Should I add the error to the “non_field_errors” of the form? If so, what’s the correct way of doing this?

My current approach is to pass a list of errors, including the reCaptcha error, from the view to the form constructor and have the errors added to the form’s non_field_errors in the init(). The way I add errors to the form’s non_field_errors (referenced post), however, is insufficient though. When there are multiple errors in the list passed, the latter one always overwrites the one before it. How can I append errors to the form’s non_field_errors rather then overwriting the existing one each time?

views.py:

def create_account(request):
    """ User sign up form """
    if request.method == 'POST':
        recaptcha_result = check_recaptcha(request)
        if recaptcha_result.is_valid:
            ...
        else:
            non_form_errors = ['Incorrect reCaptcha word entered. Please try again.'];
            signup_form = SignUpForm(request.POST, non_form_errors=non_form_errors)
    else:
        signup_form = SignUpForm()

    public_key = settings.RECAPTCHA_PUBLIC_KEY
    script = displayhtml(public_key=public_key)

    return render(request, 'create_account.html', 
        {'signup_form': signup_form, 'script': script})

forms.py:

class SignUpForm(UserCreationForm):
""" Require email address when a user signs up """
email = forms.EmailField(label='Email address', max_length=75, widget=TextInput(attrs={'size': 30}))

def __init__(self, *args, **kwargs):
    non_form_errors = []
    if kwargs.has_key('non_form_errors'):
        non_form_errors.append(kwargs.pop('non_form_errors'))

    super(SignUpForm, self).__init__(*args, **kwargs)

    for err in non_form_errors:
        self.errors['__all__'] = self.error_class(err)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:28:14+00:00Added an answer on May 23, 2026 at 8:28 pm

    First, I would like to thank @lazerscience for pointing out a better direction for a solution to my problem. I, however, didn’t adopt the django-recaptcha app as suggested.

    I ended up using a code snippet from Marco Fucci. In a quick summary, this code snippet helps you to create a custom form field (and widget) for ReCaptcha. Once this is in place, all you need to do to have ReCaptcha on your form is as simple as adding one line to the form definition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the situation. This small company I'm working with wants to have a
This is often situation, but here is latest example: Companies have various contact data
Here is my situation: I have my mvc-config.xml file for my web service set
Here's the situation: - I have <customErrors mode=On defaultRedirect=error.html /> in my web.config. I
Here's the situation: I have a label's text set, immediately followed by a response.redirect()
Here is the situation: I have been called upon to work with InstallAnywhere 8,
Here's the situation: we have an Oracle database we need to connect to to
Here is my situation: I have an application that use a configuration file. The
Here's the situation: We have some generic graphics code that we use for one
I have a very common situation here. And for years I haven't found if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.