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 9035533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:46:51+00:00 2026-06-16T08:46:51+00:00

Can anyone spot what I’m doing wrong in the following example. Validating messages are

  • 0

Can anyone spot what I’m doing wrong in the following example. Validating messages are not appearing in my template when incorrect details are entered such as a invalid email address. The template is loading and there are no errors.

I’m excepting validation messages to be printed on page, however for some reason this has suddenly stop working. As you can see from the code example below I’m passing the form in the context back to the template. this used to work and today just stopped.

view.py

if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            # If form has passed all validation checks then continue to save member.
            user = User.objects.create_user(
                                            username=form.cleaned_data['username'],
                                            email=form.cleaned_data['email'], 
                                            password=form.cleaned_data['password']
                                            )
            user.save()
            #member = User.get_profile()
            #member.name = form.cleaned_data['name']
            #member.save()
            member = Member(
                            user=user,
                            name=form.cleaned_data['name']
                            )
            member.save()

            # Save is done redirect member to logged in page.
            return HttpResponseRedirect('/profile')
        else:
            # If form is NOT valid then show the registration page again.
            form = RegistrationForm() 
            context = {'form':form}
            return render_to_response('pageRegistration.html', context,context_instance=RequestContext(request))

form.py

class RegistrationForm(ModelForm):
    username = forms.CharField(label=(u'User Name'))
    email = forms.EmailField(label=(u'Email'))
    password = forms.CharField(label=(u'Password'), widget=forms.PasswordInput(render_value=False))
    passwordConfirm = forms.CharField(label=(u'Confirm Password'), widget=forms.PasswordInput(render_value=False))

    class Meta:
        model = Member
        # Don't show user drop down.
        exclude = ('user',)


    def clean_username(self):
        username = self.cleaned_data['username']
        try:
                User.objects.get(username=username)
        except User.DoesNotExist:
                return username
        raise forms.ValidationError("Username already taken.")


    def clean(self):
        try:   
            cleaned_data = super(RegistrationForm, self).clean() 
            password = cleaned_data.get("password")
            passwordConfirm = cleaned_data.get('passwordConfirm')

            if password != passwordConfirm:
                raise forms.ValidationError("Password does not match, try again.")
            return cleaned_data
        except:
            raise forms.ValidationError("Error")

pageRegistration.html

<form action="" method="POST">
            {% csrf_token %}

            {% if forms.errors %}
            <p>
                correct some stuff
            </p>
            {% endif %}

            {{form}}
            <br>
            <input type="submit" value="submit">
        </form>  
  • 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-06-16T08:46:54+00:00Added an answer on June 16, 2026 at 8:46 am

    Since, the form is not validate in the else clause your form variable is overriden with a new form where it looses all of the errors

    if request.method == 'POST':
            form = RegistrationForm(request.POST)
            if form.is_valid():
                # If form has passed all validation checks then continue to save member.
                user = User.objects.create_user(
                                                username=form.cleaned_data['username'],
                                                email=form.cleaned_data['email'], 
                                                password=form.cleaned_data['password']
                                                )
                user.save()
                #member = User.get_profile()
                #member.name = form.cleaned_data['name']
                #member.save()
                member = Member(
                                user=user,
                                name=form.cleaned_data['name']
                                )
                member.save()
    
                # Save is done redirect member to logged in page.
                return HttpResponseRedirect('/profile')
            return render_to_response('pageRegistration.html', context,context_instance=RequestContext(request))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone spot where I might be going wrong with the following code? <?php
Can anyone spot what is wrong with my code? I'm getting a 404 Not
Can anyone spot why the following script is not printing the passed arguments? import
Can anyone spot what is wrong with this URL rewrite? I can't get it
I'm not entirely sure what I'm doing wrong, and I can't figure out how
Can anyone spot anything that would be causing me massive problems between the following
For some reason my Telerik MVC Editor() is not working. Can anyone spot what
Can anyone help me spot the problem on this PLEASE? I'm eternally grateful for
Can anyone tell me why this code would not be working? $('body').on('test', function() {
Can anyone spot the reason why nothing gets printed onto console using below C++

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.