#36699: Clarify behavior and documentation for login (404) and logout (405) 
routes
-------------------------------------+-------------------------------------
     Reporter:  yydsjkl              |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Uncategorized        |                  Version:  5.2
     Severity:  Normal               |               Resolution:
     Keywords:  login, logout,       |             Triage Stage:
  authentication, confusion          |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by yydsjkl):

 ### Proposed Fix
 Below is a proposed fix for the login page (404) issue discussed in this
 ticket.
 This fix demonstrates how a Django project can manually define a login
 route, view, and template.
 It also helps clarify to new users why the default `/login/` route does
 not exist.

 ```python
 # mysite/urls.py
 from django.urls import path
 from . import views

 urlpatterns = [
     path('admin/', admin.site.urls),
     path('login/', views.login_view, name='login'),  # Added login route
 ]
 # myapp/views.py
 from django.shortcuts import render

 def login_view(request):
     return render(request, 'login.html')
 <!-- templates/login.html -->
 <h1>Login Page</h1>
 <form method="post">
   {% csrf_token %}
   <input type="text" name="username" placeholder="Username">
   <input type="password" name="password" placeholder="Password">
   <button type="submit">Login</button>
 </form>
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36699#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019a37904131-6f80ad6f-1b82-41a5-8f59-f170fe2cf8cf-000000%40eu-central-1.amazonses.com.

Reply via email to