8👍
✅
This is how I test for the content type. In very few cases my code decides the content-type itself, so I to check that I personally did not do something wrong. DRF code is already tested.
self.assertEqual("application/json", resp['Content-Type'])
You just have to rely on DRF doing it right, its not something you can or need to test. For example, you don’t test that DRF parsed your json body correctly. The test server isn’t exactly like the real one, but its pretty close. For example, you will get real objects out of response.data, not the json encoded/decoded ones.
Check out the LiveServerTestCase if you need it, but it will be slower.
1👍
I ran into something similar and this worked for me:
response = self.client.get(self.VIEW_URL, HTTP_ACCEPT='application/json')
- [Django]-Schemamigration/refactor model using south
- [Django]-Error in shell: doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
Source:stackexchange.com