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

  • Home
  • SEARCH
  • 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 8452427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:29:50+00:00 2026-06-10T11:29:50+00:00

I am getting the error of The view registration.views.login didn’t return an HttpResponse object.

  • 0

I am getting the error of The view registration.views.login didn’t return an HttpResponse object.

I am making an login app and I wants that when I click on login button the home page is shown to me.

When I am running view.py as given then I am getting the error of Page not found localhost:8000/registration/home.html

from django.template import  loader
from django.shortcuts import render
from registration.models import Registration
from django.http import HttpResponse
from django.template import RequestContext


def login(request):
    t = loader.get_template('registration/login.html')

    return render(request, 'registration/login.html')

The urls.py file is as:

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

    urlpatterns = patterns('',
        url(r'^polls/$', 'polls.views.index'),
        url(r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'),
        url(r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'),
        url(r'^polls/(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
        url(r'^admin/', include(admin.site.urls)),
        url(r'^registration/$', 'registration.views.login'),

and when I am try to run view.py as:

from django.template import  loader
from django.shortcuts import render
from registration.models import Registration
from django.http import HttpResponse
from django.template import RequestContext

def login(request):
   t = loader.get_template('registration/login.html')
   if request.method == "POST":
    username = request.POST['user_name']
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user is not None:
      if user.is_active:
        login(request, user)
        # success
        return render_to_response(request,'registration/login.html')

then I am getting the error The view registration.views.login didn’t return an HttpResponse object.
The urls.py file remain same for this view.py

  • 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-10T11:29:51+00:00Added an answer on June 10, 2026 at 11:29 am

    You don’t need to load the template in each method; django will take care of that for you. Django requires that all methods that take are called from urls.py return a HttpResponse object.

    Your method has lots of conditions where the return statement will never be reached. For example, what if the user is not active? What if request is not POST?

    Try this version, which redirects the user back to the registration page if any of the conditions fail:

    def login(request):
       # t = loader.get_template('registration/login.html') - not needed
       if request.method == "POST":
        username = request.POST.get('user_name')
        password = request.POST.get('password')
        user = authenticate(username=username, password=password)
        if user is not None:
          if user.is_active:
            login(request, user)
            # success
            return render(request,'registration/login.html')
          else:
            # user was not active
            return redirect('registration/')
        else:
            # not a valid user
            return redirect('registration/')
       else:
           # URL was accessed directly
           return redirect('registration/')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an error on a view when I move my app to
I keep getting this error when I try and view my register user page
I am trying to launch an initial login/registration screen before my TabBarController View loads.
I am getting an error in my view: Warning (512): SQL Error: 1054: Unknown
Am getting error when getting images from sdcard folder and view in gridview. My
getting error while try to start service
Getting error when I tried like this: $ci =& get_instance(); $ci->db->select(CONCAT_WS(' ',users.name_first,users.name_last) AS user_name,CONCAT_WS('
Getting error while inserting values into database (SQL Server 2008) Implicit conversion from data
Now getting error Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
Update getting error when i try to call the method from Activity: SQLiteDatabase db

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.