Fix register url
This commit is contained in:
parent
d1de7715d7
commit
204d7bf1c5
@ -7,7 +7,7 @@
|
||||
{% endblock breadcrumbs %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post" action="{% url 'login' %}">
|
||||
<form method="post" action="{% url 'register' %}">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
|
||||
|
@ -2,6 +2,7 @@ from django.shortcuts import render, get_object_or_404, redirect, reverse
|
||||
from .models import Album, Photo
|
||||
from .forms import PhotoForm, AlbumForm
|
||||
from django.contrib.auth.forms import UserCreationForm as RegisterForm
|
||||
from django.contrib.auth import login
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
@ -11,10 +12,12 @@ from app.forms import PhotoEditForm
|
||||
def register(request):
|
||||
if request.method == "POST":
|
||||
form = RegisterForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
|
||||
return redirect("/")
|
||||
|
||||
login(request, form.instance)
|
||||
return redirect(reverse("index"))
|
||||
else:
|
||||
form = RegisterForm()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user