Redirect to the django project
good afternoon, there was a problem when creating the project. the situation is as follows, the built-in view logout does not work correctly. when I log out of the project on the site page on behalf of the user, I will be redirected to http://127.0.0.1:8000/users/logout /. moreover, everything is working properly in another project. below are the variables from the settings file, urls and the button template:
urls.py
from django.contrib.auth.views import LoginView, LogoutView
from django.urls import path
from users.apps import UsersConfig
from users.views import RegisterView, ProfileView
app_name = UsersConfig.name
urlpatterns = [
path('', LoginView.as_view(template_name='users/login.html'), name='login'),
path('logout/', LogoutView.as_view(next_page='users:login'), name='logout'),
path('register/', RegisterView.as_view(), name='register'),
path('profile/', ProfileView.as_view(), name='profile'),
]
settings.py
AUTH_USER_MODEL = 'users.User'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
template
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Меню</h4>
<ul class="list-unstyled">
<li><a href="{% url 'catalog:home' %}" class="text-white">Главная</a></li>
<li><a href="{% url 'catalog:contact' %}" class="text-white">Контакты</a></li>
<li><a href="{% url 'blog:blog' %}" class="text-white">Блог</a></li>
{% if user.is_authenticated %}
<li><a href="{% url 'users:logout' %}" class="text-white">Выйти</a></li>
<li><a href="{% url 'users:profile' %}" class="text-white">Профиль</a></li>
{% else %}
<li><a href="{% url 'users:login' %}" class="text-white">Войти</a></li>
<li><a href="{% url 'users:register' %}" class="text-white">Регистрация</a></li>
{% endif %}
</ul>
</div>
redirect to the main page
Try this
LOGIN_REDIRECT_URL = 'profile'
LOGOUT_REDIRECT_URL = 'login'