1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
validate_templates
==================
:synopsis: Checks templates on syntax or compile errors.
This will catch any invalid Django template syntax, for example::
{% foobar %}
{% comment %}
This throws this error:
TemplateSyntaxError Invalid block tag on line 1: 'foobar'. Did you forget to register or load this tag?
{% endcomment %}
Note that this will not catch invalid HTML, only errors in the Django template
syntax used.
Options
-------
verbosity
~~~~~~~~~
A higher verbosity level will print out all the files that are processed
instead of only the ones that contain errors.
break
~~~~~
Do not continue scanning other templates after the first failure.
ignore-app
~~~~~~~~~~
Ignore this app (can be used multiple times).
includes
~~~~~~~~
Use -i (can be used multiple times) to add directories to the TEMPLATE DIRS.
no-apps
~~~~~~~
Do not automatically include app template directories.
Settings
--------
VALIDATE_TEMPLATES_IGNORE_APPS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ignore the following apps
VALIDATE_TEMPLATES_IGNORES
~~~~~~~~~~~~~~~~~~~~~~~~~~
Ignore file names which matches these patterns.
Matching is done via `fnmatch`.
VALIDATE_TEMPLATES_EXTRA_TEMPLATE_DIRS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can use `VALIDATE_TEMPLATES_EXTRA_TEMPLATE_DIRS` to include a number of template
dirs by default directly from the settings file. This can be useful for situations
where TEMPLATE DIRS is dynamically generated or switched in middleware, or when you
have other template dirs for external applications like celery, and you want to
check those as well.
Usage Example
-------------
::
./manage.py validate_templates
You can also integrate it with your tests, like this::
import unittest
from django.core.management import call_command
class MyTests(unittest.TestCase):
def test_validate_templates(self):
call_command("validate_templates")
# This throws an error if it fails to validate
|