How to use 'django templateview' in Python

Every line of 'django templateview' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
337@require_jinja2
338def test_template_engine(self):
339 """
340 A template view may provide a template engine.
341 """
342 request = self.rf.get('/using/')
343 view = TemplateView.as_view(template_name='generic_views/using.html')
344 self.assertEqual(view(request).render().content, b'DTL\n')
345 view = TemplateView.as_view(template_name='generic_views/using.html', template_engine='django')
346 self.assertEqual(view(request).render().content, b'DTL\n')
347 view = TemplateView.as_view(template_name='generic_views/using.html', template_engine='jinja2')
348 self.assertEqual(view(request).render().content, b'Jinja2\n')
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

87def registration_view(template):
88 """Helper function to return TemplateViews."""
89 return TemplateView.as_view(template_name='registration/%s' % template)

Related snippets