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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:18:51+00:00 2026-06-09T10:18:51+00:00

As part of form validation, the password and password2 are compared. This is part

  • 0

As part of form validation, the password and password2 are compared. This is part of a simplified ajax request system for an extremely small site returning small amounts of data (so i don’t use JSON). The idea/objective/summery of the program is that it tries to log in the user. If the user does not exist, it asks the client side to load/reveal the form for new users (just an added password2 field and asks for a pen name). Here is the file, I’ve marked the sport where the program freezes with #*********

Forms.py (error is not here):

class new_user(forms.Form):
    username = forms.EmailField()
    password = forms.PasswordInput()
    password2 = forms.PasswordInput()
    pen_name = forms.CharField(max_length=30)

Views.py, where the error is:

def user_log_in(request):
    #add stuff for ajax request
    user_pass = log_in(request.POST)
    er = []
    if user_pass.is_valid():
        print "valid"
        cleaned_info = user_pass.cleaned_data
        user_object = User.objects.filter(email = cleaned_info['username'])
        if user_object.exists():
            logged_in_user = auth.authenticate(username=cleaned_info['username'], auth_password=cleaned_info['password'])
            #add in is_active
            if logged_in_user is not None:
                auth.login(request, logged_in_user)
                return HttpResponseRedirect('/home')
            else:
                er.append("Incorrect Password")
        else:
            new_user_pass = new_user(request.POST)
            if new_user_pass.is_valid():
                cleaned_info_new = new_user_pass.cleaned_data
                print "check points"
                if cleaned_info_new['password'] == cleaned_info_new['password2']: #********
                    print "clean"
                    new_user_query = creat_user(
                        username=cleaned_info_new['username'],
                        password=cleaned_info_new['password'],
                        email=cleaned_info_new['username']
                    )
                    new_user_query.save()
                    msg = ""
                    try:
                        send_mail("Activate", msg,  'mrgnippy@gmail.com',
                            [cleaned_info['username']], fail_silently=False)
                    except:
                        er.append("Error Sending Email")
                else:
                    er.append('Passwords are not the same')
            elif "TN" in request.POST:
                print "TN"
                for e in new_user_pass.errors:
                    er.append(e)
            #elif to check for is_active
            else:
                print "n_usr"
                return HttpResponse('n_usr')
    else:
        for e in user_pass.errors:
            er.append(e)
        for e in er:
            print"-"
            print e
            print"-"
    return HttpResponse('SOS')

The django debug page says the following:

KeyError at /ajax/login 'password' Request Method: POST Request URL: http://127.0.0.1:8000/ajax/login Django Version: 1.4 Python Executable: 

The post variable stuff in the error is this (I blanked out my email and):

GET: No GET data POST: username = u'********@aol.com' TN = u'TN' password2 = u'test' password = u'test' pen_name = u'testing123' FILES: No FILES data

Just in case the problem is here, I’ve included the javascript file.

n_usr = false;
function log_in () {
    if(!$('#pass_enter').hasClass('#usr_enter')){
        password = $('#pass_enter').val();
    }else{
        password = '';
    }
    if(!$('#usr_enter').hasClass('blur_field')){
        username = $('#usr_enter').val();
    }else{
        username = '';
    }
    alert(username);

    if(!n_usr){
        $.post('/ajax/login',{password: password, username: username}, function(data) {
            if(data == "n_usr"){
                $('#new_user_entry').show('slow');
                n_usr = true;
            }
            else {

            }

        })
    }else {
        if (!$('#pass_re_enter').hasClass('blur_field')){
                password2 = $('#pass_re_enter').val();
        }else {
                password2 = '';
        }
        if (!$('#pass_re_enter').hasClass('blur_field')){
            penname = $('#pen_enter').val();
        }else {
            penname = '';
        }
            $.post('/ajax/login', {password: password, password2: password2, username: username, pen_name: penname, TN: "TN"}, function(data) {
                if(data == "e_act"){

                } else {

                }
            });
        }
    }
  • 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-09T10:18:53+00:00Added an answer on June 9, 2026 at 10:18 am

    I just noticed that I used the wrong fields in the forms.py file. Problem solved.

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

Sidebar

Related Questions

I have a simple HTML form that uses uses ajax in part of the
As part of a form validation in Django, I want to check when a
In my JSF/Facelets app, here's a simplified version of part of my form: <h:form
ScalaForms In the example linked here there is this example about form validation: //
I have a multi-part form with three different sets of validation (each fieldset). Each
I am working on a 2 part form to allow users to create posts
I am trying to post a multi-part form using httplib, url is hosted on
I am getting a strange behavior for multi-part form. I have a simple HTML
InfoPath form web part can be used to fill out a published InfoPath form
I'm using the following form as part of an Advanced Search page on my

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.