Chapter4: POST http://127.0.0.1:8000/api/v1/accounts/ 405 (Method Not Allowed)
POST http://127.0.0.1:8000/api/v1/accounts/ 405 (Method Not Allowed)
Can you push your repo to Github so I can take a look?
sure, here it is: https://github.com/soufiaane/CVC.git & great work by the way. thanks
Please I am also getting this same error. "POST /api/v1/auth/login/ HTTP/1.1" 405 0. how did you fix it?
I fixed this error after about 24hrs of tackling the problem. The main problem is a "TypeError: the JSON object must be str, not 'bytes'" Which is returned by this Line - "data = json.loads(request.body)" in your views.py. But if you are receiving the - POST /api/v1/auth/login/ HTTP/1.1" 405 0 This is because Django Python is talking to the Wrong view in another views.py class LoginView(TemplateView): template_name = 'login.html'
@method_decorator(ensure_csrf_cookie)
def dispatch(self, *args, **kwargs):
return super(LoginView, self).dispatch(*args, **kwargs)
Remove this import from your urls.py and make sure to import only the LoginView from authentication app, this - from authentication.views import AccountViewSet, LoginView Then change this line in authentication.views.py from #data = json.loads(request.body) to data = request.data. I had to contact the developer of DRF to get this solution. I hope it helps.