url(r'^$', 'habr.views.index', name='habr_home'),
url(r'^$', 'habr.views.index', name='habr_register'),
url(r'^$', 'PersonRegistration', name = 'register-form'),
— для регистрацииurl(r'^$', 'LoginRequest', name = 'login-form'),
— для входа на сайт
def PersonRegistration(request):
if 'auth' in request.POST:
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(username = form.cleaned_data['username'],
email = form.cleaned_data['email'],
password = form.cleaned_data['password'])
user.save()
person = Person(user = user,
first_name = form.cleaned_data['first_name'],
last_name = form.cleaned_data['last_name'],
email = form.cleaned_data['email'],
password = form.cleaned_data['password'])
person.save()
return HttpResponseRedirect('/profile/')
else:
return render_to_response('home.html', { 'form' : form }, context_instance = RequestContext(request))
else:
''' user not submitting the form, show them a blank registration form.'''
form = RegistrationForm()
context = { 'form' : form }
return render_to_response('home.html', context, context_instance = RequestContext(request))
def PersonRegistration(request):
if 'auth' in request.POST:
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(username = form.cleaned_data['username'],
email = form.cleaned_data['email'],
password = form.cleaned_data['password'])
user.save()
person = Person(user = user,
first_name = form.cleaned_data['first_name'],
last_name = form.cleaned_data['last_name'],
email = form.cleaned_data['email'],
password = form.cleaned_data['password'])
person.save()
return HttpResponseRedirect('/profile/')
else:
return render_to_response('home.html', { 'form' : form }, context_instance = RequestContext(request))
else:
''' user not submitting the form, show them a blank registration form.'''
form = RegistrationForm()
context = { 'form' : form }
return render_to_response('home.html', context, context_instance = RequestContext(request))
<img class="captcha" alt="captcha" src="/captcha/image/f02f54ef2a90e5920f28ed1fad9753f06e9a1115/"> <input id="id_captcha_0" type="hidden" value="f02f54ef2a90e5920f28ed1fad9753f06e9a1115" name="captcha_0"> <input id="id_captcha_1" type="text" name="captcha_1">
а отображается, как обычное текстовое поле…