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))
C:\Projects\registration>manage.py test captcha
Traceback (most recent call last):
File «C:\Projects\registration\manage.py», line 10, in execute_from_command_line(sys.argv)
File «C:\Python27\lib\site-packages\django\core\management\__init__.py», line
443, in execute_from_command_line
utility.execute()
File «C:\Python27\lib\site-packages\django\core\management\__init__.py», line
382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File «C:\Python27\lib\site-packages\django\core\management\commands\test.py»,
line 49, in run_from_argv
super(Command, self).run_from_argv(argv)
File «C:\Python27\lib\site-packages\django\core\management\base.py», line 196,
in run_from_argv
self.execute(*args, **options.__dict__)
File «C:\Python27\lib\site-packages\django\core\management\base.py», line 232,
in execute
output = self.handle(*args, **options)
File «C:\Python27\lib\site-packages\django\core\management\commands\test.py»,
line 72, in handle
failures = test_runner.run_tests(test_labels)
File «C:\Python27\lib\site-packages\django\test\simple.py», line 380, in run_t
ests
suite = self.build_suite(test_labels, extra_tests)
File «C:\Python27\lib\site-packages\django\test\simple.py», line 263, in build
_suite
app = get_app(label)
File «C:\Python27\lib\site-packages\django\db\models\loading.py», line 152, in
get_app
raise ImproperlyConfigured(«App with label %s could not be found» % app_labe
l)
django.core.exceptions.ImproperlyConfigured: App with label captcha could not be
found