Answer the question
In order to leave comments, you need to log in
How to make the registration form and the login form on the same page?
Hello.
Tell me please.
There is a registration form and an entrance to the site, which are located on the same page and have one urls.
#urls.py
urlpatterns = patterns('users.views',
url(r'^$', 'PersonRegistration', name = 'Home Page'),
url(r'^$', 'LoginRequest', name = 'Home Page'),
)
#views.py
def PersonRegistration(request):
...
def LoginRequest(request):
...
Answer the question
In order to leave comments, you need to log in
<form>
<input type="hidden" name="form" value="registration" />
</form>
<form>
<input type="hidden" name="form" value="auth" />
</form>
And I would advise you to separate these two pages =) After all, they do different things, why sculpt everything in one place?
Some wildness.
What for to process registration and an input in one? Okay, you can display both forms on one page, if it really itchs. But to process!
The easiest way is to make a separate page with both forms. Output only, no processing.
First write the view:
from django.shortcuts import render
def all_in_one(request):
return render('reg_and_login.html', {
'login_form': LoginForm(),
'register_form': RegistrationForm()
})
url(r'^$', 'all_in_one'), # Добавили
url(r'^registration/$', 'PersonRegistration', name = 'register-form'), # Изменили
url(r'^login$', 'LoginRequest', name = 'login-form'), # Изменили
<!-- reg_and_login.html -->
<form action="{% url login-form %}" method="post">
{{ login_form }}
</form>
<form action="{% url register-form %}" method="post">
{{ register_form }}
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question