login_register.html :
<form method="post" action="{% url 'register' %}">
{% csrf_token %}
{{ registration_form.as_p }}
<button type="submit">Register</button>
</form>
On Nov 24, 2017 1:42 AM, "Tom Tanner" <[email protected]> wrote:
> My page has a registration form at `"/login_register/"`. I want the form
> to send a POST request to `"/register/"`. Here's my code so far.
>
> `urls.py`:
> url("^login_register/$", views.login_register, name="login_register"),
> url("^register/$", views.register, name="register"),
>
>
> `views.py`:
> def login_register(request, template="pages/login_register.html"):
> '''
> Display registration and login forms
> '''
> registration_form= RegisterForm()
> return render(request, template, {"registration_form": registration_form
> })
>
>
> def register(request):
> '''
> Process user registration
> '''
> if request.method=="POST":
> # Some code here
>
>
> `pages/login_register.html`:
> # For this example, I only include the registration form's HTML
> <h2>Register</h2>
> <form method="post">
> {% csrf_token %}
> {{ registration_form.as_p }}
> <button type="submit">Register</button>
> </form>
>
>
> When I hit "Register" on the form, my browser sends a POST request to
> "login_register/". I want it to send a POST request to "register/". How do
> I do this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/72030063-8482-4723-9f2c-b25b17656a43%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/72030063-8482-4723-9f2c-b25b17656a43%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CACOk0TwKO_D4fZh6cW3gULXTfs%2BcDrU88SShiW1SA9c8NZHz%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.