Answer the question
In order to leave comments, you need to log in
How to redirect to specified url Django?
Doesn't redirect to success_url , instead sends to main localhost:8000
class LoginFormView(FormView):
form_class = AuthenticationForm
# Аналогично регистрации, только используем шаблон аутентификации.
template_name = "registration/login.html"
# В случае успеха перенаправим на главную.
success_url = "/game/"
def form_valid(self, form):
# Получаем объект пользователя на основе введённых в форму данных.
self.user = form.get_user()
# Выполняем аутентификацию пользователя.
login(self.request, self.user)
return super(LoginFormView, self).form_valid(form)
Answer the question
In order to leave comments, you need to log in
In the settings, specify where you need to redirect:
settings.py:
...
LOGIN_REDIRECT_URL = '/game/'
...
next
<a href="{% url 'auth_login' %}?next=/game/">Auth</a>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question