97👍
✅
Try passing the query parameter as a data payload instead. Change the line in your test to:
response = self.client.get('/api/titles-and-blurbs/', {'genre': 'horror'})
Django docs here on the different ways to pass query parameters in urls.
Another person reported a similar issue with an empty QUERY_PARAMS
while testing DRF (see here). It looks like they fixed it but maybe they missed something or you didn’t get the update.
👤Alex
0👍
If someone comes across this, for me it helped to:to change the url from
/api/titles-and-blurbs?genre=horror
to
/api/titles-and-blurbs/?genre=horror
Both urls were working find in Postman, but only the second one is working properly in the tests.
👤SAM
- [Django]-How does Django Know the Order to Render Form Fields?
- [Django]-Django development server reload takes too long
- [Django]-Adding model-wide help text to a django model's admin form
Source:stackexchange.com