Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

Django Error 405 - Method Not Allowed (POST), can't figure out the cause

$
0
0

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/loginMethod Not Allowed: api/users/login"POST api/users/login HTTP/1.1" 405 0

views.py

@csrf_protectdef 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

enter image description here


Viewing all articles
Browse latest Browse all 3630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>