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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:18:00+00:00 2026-05-25T22:18:00+00:00

I want to register users. So I made a: class RegisterForm(ModelForm): class Meta: model=User

  • 0

I want to register users.
So I made a:

class RegisterForm(ModelForm):
    class Meta:
        model=User #(from django.auth.contrib.User)

now i display that form in a template for the users to fill it and to submit it.
When i do form.is_valid(), i get this validation error: Your username and password didn't match. Please try again.

Does anyone know what can cause this?
i’ve included the ModelForm, the view that processes the registration form and the template that displays the registration form.
Thank you for your time and kind concern.

MY MODEL FORM
class RegisterForm(ModelForm):
    class Meta:
        model=User

THE VIEW THAT HANDLES THE REGISTRATION
def register(request):
    if request.method=='POST':
        form=RegisterForm(request.POST)
        if form.is_valid(): # HERE I GET A VALIDATION ERROR
            new_user=User.objects.create_user(username=form.cleaned_data['username'],
                                          password=form.cleaned_data['password'],
                                          email=form.cleaned_data['email'],
                                          )
            new_user.is_active=True
            new_user.first_name=form.cleaned_data['first_name']
            new_user.last_name=form.cleaned_data['lastname']
            return HttpResponseRedirect(reverse('confirm_registered'),args=[form.cleaned_data['username']])
        else:
            return render(request,'login/register.html',{'form':form})
    else:
        raise ValueError()

THE REGISTRATION TEMPLATE

{% extends "store/index2.html" %}

{% block canvas %}
<h3>Registration</h3>


{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}

<form method="post" action="/retailstore/login/register.html">
{% csrf_token %}
<table>
<tr>
    <td>{{ form.username.label_tag }}</td>
    <td>{{ form.username }}</td>
</tr>
<tr>
    <td>{{ form.password.label_tag }}</td>
    <td>{{ form.password }}</td>
</tr>
<tr>
    <td>{{ form.first_name.label_tag }}</td>
    <td>{{ form.first_name }}</td>
</tr>
<tr>
    <td>{{ form.last_name.label_tag }}</td>
    <td>{{ form.last_name }}</td>
</tr>
<tr>
    <td>{{ form.email.label_tag }}</td>
    <td>{{ form.email }}</td>
</tr>

</table>

<input type="submit" value="register" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
{% endblock %}
  • 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-25T22:18:01+00:00Added an answer on May 25, 2026 at 10:18 pm

    The form is not validating, but your template is set to always show the same error message about username and password not matching:

    {% if form.errors %}
    <p>Your username and password didn't match. Please try again.</p>
    {% endif %}
    

    The reason it is not validating is probably because you are only using some of the fields from the User object, and a ModelForm expects all of the non-editable fields. In the Form’s Meta, set

     fields = 'username', 'password', 'first_name', 'last_name', 'email'
    

    to tell it to only require those fields.

    Also note that passwords are not stored in the database as plain text, so creating a user with a password like that will not work. You need to use user.set_password(form_password).

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

Sidebar

Related Questions

I want to register user clicked on ads and save users info to database
i want to register my app users through http. what i have now is:
I want to build a web application where users can register and have a
I want to create a web application that allows users to sign up, register
In my web application i have registration form, when user register i want to
I started out with Django some days ago and I have now made a
i have made user-register.tpl.php file. And i have set many text field in that.
I made this loader which actually works pretty well. I now want to make
I have registration box,and I want users to register via ajax. Is it safe
When a user registers with my site I want to offer them a login

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.