49👍
✅
You have defined a url that matches /query/
, but you are testing /query
. Django is redirecting to the url with the trailing slash because APPEND_SLASH=True
in your settings.
You probably want to change your test to:
response = self.client.post('/query/', {})
12👍
For me, the problem was that I mistakenly ran the tests with a setting.py
file that had SECURE_SSL_REDIRECT = True
. Changing to SECURE_SSL_REDIRECT = False
solved the issue.
Another option is to use the client
with secure=True
, i.e.:
response = self.client.post('/query/', {}, secure=True)
which will make the client emulate an HTTPS request.
- [Django]-How can I use Bootstrap with Django?
- [Django]-What's the best way to handle Django's objects.get?
- [Django]-Django: How can I identify the calling view from a template?
Source:stackexchange.com