I’m using Python 3.10.6, Django 4.2.10, Django REST Framework 3.15.1
I have a login page in JavaScript sending POST request to Django with user credentials (and CSRF token in header), but the login view doesn’t even open, I immediately get said error:
Method Not Allowed (POST): api/users/login
Method Not Allowed: api/users/login
“POST api/users/login HTTP/1.1” 405 0
views.py
@csrf_protect
def login_view(request):
if request.method == "POST":
....
urls.py
from .views import login_view, ...
urlpatterns = [
...
path('api/users/login', login_view, name='login_view'),
...
]
I can’t figure out what’s causing the 405
I tried deleting the @csrf_protect but didn’t change anything
error405