Answer the question
In order to leave comments, you need to log in
I specify one view for url, and fulfills another?
urls.py
from django.conf.urls import url
from staff import views
urlpatterns = [
url(r'^$', views.index, name='staff'),
url(r'(?P<username>[-\w]+)/$', views.user, name='user'),
url(r'(?P<username>[-\w]+)/logout/$', views.logout, name='user_logout'),
]
def user(request, username):
print('user')
return render(request, 'staff/index.html', locals())
def logout(request, username):
print('test')
auth.logout(request)
username = None
print('test')
return redirect('staff/index.html', locals())
<a href="{% url 'user_logout' user %}" class="btn btn-sm btn-danger ion-log-out">Выход</a>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question