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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:57:04+00:00 2026-05-28T02:57:04+00:00

models.py: class Users(models.Model): username = models.CharField(max_length=255) slug = models.CharField(max_length=255, default=’0′) password = models.CharField(max_length=300) passwordrepeat

  • 0

models.py:

class Users(models.Model):
    username = models.CharField(max_length=255)
    slug = models.CharField(max_length=255, default='0')
    password = models.CharField(max_length=300)
    passwordrepeat = models.CharField('Repeat Password', max_length=300)
    password_token = models.CharField(max_length=300, default='0')
    email = models.CharField(max_length=255)
    email_verified = models.BooleanField(default=False)
    email_token = models.CharField(max_length=255)
    email_token_expiry = models.DateTimeField(auto_now_add=True)
    tos = models.BooleanField(default=False)
    active = models.BooleanField(default=False)
    last_login = models.DateTimeField(auto_now_add=True)
    last_action = models.DateTimeField(auto_now_add=True)
    is_admin = models.BooleanField(default=False)
    role = models.CharField(max_length=255, default='0')
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return self.username

class UsersModelForm(forms.ModelForm):
    class Meta:
        model = Users
        fields = ('username', 'password', 'passwordrepeat', 'email')
        widgets = {
            'password' : PasswordInput(),
            'passwordrepeat' : PasswordInput(),
        }

views.py:

def register(request):
    flag = True
    possible = '0123456789abcdefghijklmnopqrstuvwxyz'
    token = ''
    length = 10
    i = 0

    current_datetime = datetime.datetime.now()

    user = UsersModelForm()
    if request.method == 'POST':
        userf = UsersModelForm(request.POST)
        username = userf.data['username']
        password = userf.data['password']
        passwordrepeat = userf.data['passwordrepeat']
        email = userf.data['email']

        if password != passwordrepeat:
            flag = False
            passVariable = {'user':user, 'flag': False}
            return render_to_response('register.html', passVariable, context_instance=RequestContext(request))

        elif password == passwordrepeat:
            while i<10:
                temp = random.choice(possible)
                token = token + temp
                i=i+1

            userf.email_token = token
            userf.email_token_expiry = current_datetime + timedelta(1)
            userf.save()
            return HttpResponseRedirect('/')
    else:
        return render_to_response('register.html', {"user": user, 'flag': True}, context_instance=RequestContext(request))

In template:

<div id="id_div_register">
    <form action="/register" method="POST">{% csrf_token %}
        {{ user.as_p }}
        <input type=submit value="Submit" />
    </form>
</div>

This form creates a textbox ‘repeatpassword’ because of the field in models.py. I don’t want to have a field ‘repeatpassword’ in the mysql table field/column. But i need to compare ‘password’ with ‘repeatpassword’ in template. How can i do it?

I need ‘password’ and ‘repeatpassword’ in template to compare these two, but i don’t need a column/field ‘repeatpassword’ in blog_users mysql table. How can i do it? Is it possible to do it.

  • 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-28T02:57:05+00:00Added an answer on May 28, 2026 at 2:57 am

    Your need a new field on the form which is cleaned to check the passwords match, then you can remove the password checks within your view and replace with form.is_valid(). Something like the following:

    class UsersModelForm(forms.ModelForm):
        passwordrepeat = forms.PasswordInput()
        class Meta:
            model = Users
    
        def clean(self):
            cleaned_data = self.cleaned_data
            password = cleaned_data.get("password")
            passwordrepeat = cleaned_data.get("passwordrepeat")
            if password != passwordrepeat:
                raise forms.ValidationError("Passwords must match.")
    
            return cleaned_data
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

models.py: class Users(models.Model): username = models.CharField(max_length=255) slug = models.CharField(max_length=255, default='0') password = models.CharField(max_length=300) password_token
I have the following model: class User: name = models.CharField( max_length = 200 )
My models look like this: class Article(models.Model): name = models.CharField(max_length=50) description = models.TextField() price
I have the following model set up: class UserProfile(models.Model): Additional attributes for users. url
I have these models class User(models.Model): user_name = models.CharField() ph_number = models.CharField() class ExamPaper(models.Model):
Suppose I have the following models: class User(models.Model): pass class A(models.Model): user = models.ForeignKey(User)
My model is like this class Foo(models.Model): user = models.ForeignKey(User) class Meta: abstract =
here is my model class gameUserTrophyInfo(models.Model): user = models.ForeignKey(userInfo) trophy = models.ForeignKey(gameTrophyInfo) date =
Given the Model: class Profile(models.Model): user = models.ForeignKey(User, unique=True) class Thingie(models.Model): children = models.ManyToManyField('self',
I have three models: class Book < ActiveRecord::Base has_many :collections has_many :users, :through =>

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.