Reputation: 1
I was following a tutorial trying to create a registration form. Even though the person recording it was able to create a form I wasn't does anybody see any mistakes in my code? The view didn't return an HttpResponse object.
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.contrib import auth
from django.core.context_processors import csrf
from django.contrib.auth.forms import UserCreationForm
def registerit(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {'form3':UserCreationForm()}
args.update(csrf(request))
return render_to_response('register.html', args)
Thank you for your help.
Upvotes: 0
Views: 281
Reputation: 99650
You are returning a HttpResponse
object only if if request.method == 'POST':
But if the request method is __not POST
, you are not returning anything. You probably need to indent the code one level to the left.
def registerit(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {'form3':UserCreationForm()}
args.update(csrf(request))
return render_to_response('register.html', args)
Upvotes: 1