I am a newbie for Django. I have had an error like title during making pages. my system information is Django1.2, Ubuntu12.
There already has been same as my error on stackorverflow - http://goo.gl/bK5msW
def register_page(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['eamil']
)
return HttpResponseRedirect('/')
else:
form = RegistrationForm()
return render_to_response('registration/register.html', variables)
Looking like some issue with indentation, this should work for you.
def register_page(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['email']
)
return HttpResponseRedirect('/')
else:
form = RegistrationForm()
return render_to_response('registration/register.html', variables)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.