# How to test templates

**URL:** <https://forum.djangoproject.com/t/how-to-test-templates/2127>\
**Category:** Using Django\
**Created:** [April 27, 2020, 8:29am UTC](https://forum.djangoproject.com/t/how-to-test-templates/2127 "2020-04-27T08:29:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaximilianKindshofer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/maximiliankindshofer/32/835_2.png) [@MaximilianKindshofer](https://forum.djangoproject.com/u/MaximilianKindshofer)\
**Post date:** [April 27, 2020, 8:29am UTC](https://forum.djangoproject.com/t/how-to-test-templates/2127/1 "2020-04-27T08:29:09Z")

</div>

Recently I had a bug where I forgot to close some curly brackets:

` {% extends 'base.html'`

Of course the response from the test was green -\> response.status = 200 also all Items where printed on the page.

So is there a way to catch this or a Linter or something like Black for django temlates?

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [April 27, 2020, 9:17am UTC](https://forum.djangoproject.com/t/how-to-test-templates/2127/2 "2020-04-27T09:17:16Z")

</div>

I’m surprised that wasn’t a syntax error in the template because of the unclosed tag. Django should probably detect that.

But for testing - I’m not aware of any linter or similar. But I have used the coverage plugin to ensure all lines of templates have been run during tests: [https://pypi.org/project/django-coverage-plugin/](https://pypi.org/project/django-coverage-plugin/) . Not sure it would have caught your case though.

---

<div class="post-metadata">

**Author:** ![MaximilianKindshofer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/maximiliankindshofer/32/835_2.png) [@MaximilianKindshofer](https://forum.djangoproject.com/u/MaximilianKindshofer)\
**Post date:** [April 27, 2020, 9:22am UTC](https://forum.djangoproject.com/t/how-to-test-templates/2127/3 "2020-04-27T09:22:44Z")

</div>

It just renders ugly:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/3/3bb947444d60803b4939cd68c66634e3baf21b6a.png)  
but its not an syntax error and if I would test if the elements are on the page.

So this might be an unexpected behavior for Django.

_The template coverage plugin slated my coverage percentage 😆_

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [April 27, 2020, 10:07am UTC](https://forum.djangoproject.com/t/how-to-test-templates/2127/4 "2020-04-27T10:07:53Z")

</div>

> [@MaximilianKindshofer](#):
>
> but its not an syntax error and if I would test if the elements are on the page.

Yeah - maybe it should be!
