728x90
반응형
SMALL
views.py
from django.contrib.auth import authenticate, login, logout
def logoutUser(request):
logout(request)
return redirect('home')
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('login/', views.loginPage, name = "login"),
path('logout/', views.logoutUser, name = "logout"),
path('', views.home, name = "home"),
path('room/<str:pk>/', views.room, name = "room"),
path('create-room/', views.createRoom, name = "create-room"),
path('update-room/<str:pk>/', views.updateRoom, name = "update-room"),
path('delete-room/<str:pk>/', views.deleteRoom, name = "delete-room")
]
navbar.html
<a href = "/">
<h1>LOGO</h1>
</a>
<form method="GET" action="{% url 'home' %}">
<input type="text" name="q" placeholder="Search Rooms..." />
</form>
{% if request.user.is_authenticated %}
<a href="{% url 'logout' %}">Logout</a>
{% else %}
<a href="{% url 'login' %}">Login</a>
{% endif %}
<hr>
728x90
반응형
LIST
'App Programming > Django' 카테고리의 다른 글
[Django] 서버 배포 (0) | 2023.04.10 |
---|---|
[Django] Reverse for '' not found. '' is not a valid view function or pattern name. (0) | 2023.04.09 |
[Django] 프론트엔드 페이지 (0) | 2023.02.22 |
[Django] 시리얼라이저 (Serializer) (0) | 2023.02.22 |
[Django] REST API (0) | 2023.02.21 |