4👍
You should use assertTemplateUsed
(docs):
response = self.client.get('/url/')
self.assertTemplateUsed(response, 'test.html')
1👍
From:
response = self.client.get("/my/view/url")
you can do
self.assertEqual(response.templates[0].name, "expected_template.html")
or:
self.assertEqual(response.template[0].name, "expected_template.html")
as ‘template’ and ‘templates’ are the same array. Subsequent (non-zero) entries of this array list included or extended templates.
- [Django]-Django: prevent template from using a model method
- [Django]-How to create a custom 404 page for my Django/Apache?
- [Django]-Update queryset with dictionary values
- [Django]-How do I filter API results by a related model attribute using Tastypie?
Source:stackexchange.com