3👍
✅
The response has a context
attribute that contains the context used to render the template.
self.assertIn('form', response.context)
0👍
It’s possible to use assertIn but it’s better to use assertContains .
self.assertContains(response, 'form', count=None, status_code=200, msg_prefix='', html=False)
This allow you to have more options and check status_code at the same time. for example set html to True to handle text as HTML. The comparison with the response content will be based on HTML semantics instead of character-by-character equality. more info here.
- [Django]-How to expose non-model module methods via Django Rest Framework?
- [Django]-How can I setup Nginx Proxy Buffering with Gunicorn over Amazon EC2?
- [Django]-Python telegram bot: Access to contact information
- [Django]-How to include a field from the joining table in the queryset?
- [Django]-How to get a formatted DateTimeField value outside a Django template?
Source:stackexchange.com