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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:56:42+00:00 2026-05-20T21:56:42+00:00

I have created a django app. It has got a user login/registration on the

  • 0

I have created a django app. It has got a user login/registration on the same registrationForm.html. The login functionality is working fine now. Once the user gives the correct username (here email id) and password the user is redirected to another page(logedIn.html) showing a message ‘User logged in’, and when the user is invalid (wrong username or password) , the page is again rendered to that page(registrationForm.html). Now i want to show a message on that page saying “Check your username or password” . Being a django newbie i am not able to do it. Can somebody help to do this. I will paste my code here.

views.py

def registrationForm(request):
    if request.method == "POST":  
        firstName = request.POST.get("firstName")
        lastName = request.POST.get("lastName")
        email = request.POST.get("email")
        password = request.POST.get("password")
        sex = request.POST.get("sex")
        birthday = request.POST.get("birthday")
        print request.POST.get("sex")
        UniversityDetails(firstName=firstName,lastName=lastName,email=email,password=password,sex=sex,birthday=birthday).save()
        return render_to_response('registrationForm.html')
    return render_to_response("registrationForm.html")

def login(request):
    if request.POST:            
        email=request.POST.get("username")
        password = request.POST.get("password")                     
        user = UniversityDetails.objects.filter(email=email,password=password)          
        if(not user):
            return render_to_response("registrationForm.html")
        else:
            return render_to_response("logedIn.html")

html

<div align="center">
<form name="userInputForm" method="POST" id="myFormid" action="http://10.1.0.90:8080/login/">
<div style="float:left;width:100%;">
  <p style="float:left;margin-right:10px;width:auto;"><label style="float:left;">Email id</label><br/> <input type="text" name="username" size="25" /></p>
  <p style="float:left;margin-right:10px;width:auto;"><label style="float:left;">Password</label><br/><input type="password" name="password" size="25" /></p>
 </div> 
    <p style="clear:both;float:left;"><input type="submit" value="Log in" /></p>
</div>
</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-05-20T21:56:42+00:00Added an answer on May 20, 2026 at 9:56 pm

    There are massive problems with the way you are doing things – storing plaintext passwords for example — look into the built in authentication backends available to django for how to properly log a user in. Added benefits include the user being available automatically in request.user
    http://docs.djangoproject.com/en/dev/topics/auth/

    BUT, I do understand learning django one step a time. Given your code, just add a variable to the context of your template being rendered on failure.

    def login(request):
        if request.POST:            
            email=request.POST.get("username")
            password = request.POST.get("password")                     
            user = UniversityDetails.objects.filter(email=email,password=password)          
            if(not user):
                return render_to_response("registrationForm.html", 
                           {'invalid': True }) # our template can detect this variable
            else:
                return render_to_response("logedIn.html")
    

    template

    {% if invalid %}
        Your email/password combo doesn't exist. 
    {% endif %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Django app. I have a registration page(simple HTML form) in
I created a django application with a user login/registration page. I am trying to
I'm building my first django app. I have a user, and the user has
I have a Django app for which I have created a superuser account for
I have a Django app that allows the user to create variables and name
I've created a simple 'favourites' system in my django app. I have events which
I have a Django project which has two apps (one created as debug test).
I have a django app that has a horizontal navigation. For some reason I
I have a django app that has a horizontal nav. The horizontal nav looks
I would like to deplay a django application/project, which i have created within Aptana.

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.