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