53π
To be clear, whenever requests receives a redirect (with a certain status code) we have to perform certain transformations on the request.
In cases like this, when you see something very unexpected the best debugging tips are to retry your request but with allow_redirects=False
. This will immediately return the 30x response. Alternatively, you can also check r.history
to see if there are any 30x responses that were followed. In this case you probably would have seen something like
>>> r.request.method
'GET'
>>> r.history
[<Response [302]>,]
>>> r.history[0].request.method
'POST'
We know that doing this can cause unexpected behaviour for users (as it just did to you) but itβs the only correct way to operate on the web.
I hope this helps you understand why this happened beyond the fact that it was a redirect, and hopefully it gives you and others tools to debug this in the future.
29π
The problem was the RESTful API was redirecting me from http:// to https://, which caused the library to return the "second" request (GET)β¦
- [Django]-How do I see stdout when running Django tests?
- [Django]-Why would running scheduled tasks with Celery be preferable over crontab?
- [Django]-Django β How to prepopulate admin form fields