My main page contains a form. Because I want the form to appear when
I load my page my view looks like this:
from djangoproject1.authentication import forms
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
def main(request):
uf = forms.UserForm()
upf = forms.UserProfileForm()
return render_to_response("authentication/index.html", {'form1':
uf, 'form2':upf})
def register(request):
if request.method == 'POST':
uf = forms.UserForm(request.POST)
upf = forms.UserProfileForm(request.POST)
if uf.is_valid() and upf.is_valid():
user = uf.save(commit=False)
user.set_password(uf.cleaned_data["password"])
user.save()
userprofile = upf.save(commit=False)
userprofile.user = user
userprofile.save()
return HttpResponseRedirect("/register-success/")
return render_to_response("authentication/index.html", {'form1':
uf,'form2':upf})
When I visit the main page, my URLConf points me to main. If I were
to hit submit, I would be directed to register. The problem is, when
I visit the page, all of the validation error messages for my fields
are already shown for username and password.
Here's my html:
<h1>Register</h1>
<form action="/register/" method="post">
{{ form1.as_p }}
{{ form2.as_p }}
<input type="submit" value="Register">
</form>
Thanks
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.