1. ======================
    
  2. System check framework
    
  3. ======================
    
  4. 
    
  5. .. currentmodule:: django.core.checks
    
  6. 
    
  7. The system check framework is a set of static checks for validating Django
    
  8. projects. It detects common problems and provides hints for how to fix them.
    
  9. The framework is extensible so you can easily add your own checks.
    
  10. 
    
  11. For details on how to add your own checks and integrate them with Django's
    
  12. system checks, see the :doc:`System check topic guide </topics/checks>`.
    
  13. 
    
  14. API reference
    
  15. =============
    
  16. 
    
  17. ``CheckMessage``
    
  18. ----------------
    
  19. 
    
  20. .. class:: CheckMessage(level, msg, hint=None, obj=None, id=None)
    
  21. 
    
  22. The warnings and errors raised by system checks must be instances of
    
  23. ``CheckMessage``. An instance encapsulates a single reportable error or
    
  24. warning. It also provides context and hints applicable to the message, and a
    
  25. unique identifier that is used for filtering purposes.
    
  26. 
    
  27. Constructor arguments are:
    
  28. 
    
  29. ``level``
    
  30.     The severity of the message. Use one of the predefined values: ``DEBUG``,
    
  31.     ``INFO``, ``WARNING``, ``ERROR``, ``CRITICAL``. If the level is greater or
    
  32.     equal to ``ERROR``, then Django will prevent management commands from
    
  33.     executing. Messages with level lower than ``ERROR`` (i.e. warnings) are
    
  34.     reported to the console, but can be silenced.
    
  35. 
    
  36. ``msg``
    
  37.     A short (less than 80 characters) string describing the problem. The string
    
  38.     should *not* contain newlines.
    
  39. 
    
  40. ``hint``
    
  41.     A single-line string providing a hint for fixing the problem. If no hint
    
  42.     can be provided, or the hint is self-evident from the error message, the
    
  43.     hint can be omitted, or a value of ``None`` can be used.
    
  44. 
    
  45. ``obj``
    
  46.     Optional. An object providing context for the message (for example, the
    
  47.     model where the problem was discovered). The object should be a model,
    
  48.     field, or manager or any other object that defines a ``__str__()`` method.
    
  49.     The method is used while reporting all messages and its result precedes the
    
  50.     message.
    
  51. 
    
  52. ``id``
    
  53.     Optional string. A unique identifier for the issue. Identifiers should
    
  54.     follow the pattern ``applabel.X001``, where ``X`` is one of the letters
    
  55.     ``CEWID``, indicating the message severity (``C`` for criticals, ``E`` for
    
  56.     errors and so). The number can be allocated by the application, but should
    
  57.     be unique within that application.
    
  58. 
    
  59. There are subclasses to make creating messages with common levels easier. When
    
  60. using them you can omit the ``level`` argument because it is implied by the
    
  61. class name.
    
  62. 
    
  63. .. class:: Debug(msg, hint=None, obj=None, id=None)
    
  64. .. class:: Info(msg, hint=None, obj=None, id=None)
    
  65. .. class:: Warning(msg, hint=None obj=None, id=None)
    
  66. .. class:: Error(msg, hint=None, obj=None, id=None)
    
  67. .. class:: Critical(msg, hint=None, obj=None, id=None)
    
  68. 
    
  69. .. _system-check-builtin-tags:
    
  70. 
    
  71. Builtin tags
    
  72. ============
    
  73. 
    
  74. Django's system checks are organized using the following tags:
    
  75. 
    
  76. * ``admin``: Checks of any admin site declarations.
    
  77. * ``async_support``: Checks asynchronous-related configuration.
    
  78. * ``caches``: Checks cache related configuration.
    
  79. * ``compatibility``: Flags potential problems with version upgrades.
    
  80. * ``database``: Checks database-related configuration issues. Database checks
    
  81.   are not run by default because they do more than static code analysis as
    
  82.   regular checks do. They are only run by the :djadmin:`migrate` command or if
    
  83.   you specify configured database aliases using the ``--database`` option when
    
  84.   calling the :djadmin:`check` command.
    
  85. * ``files``: Checks files related configuration.
    
  86. * ``models``: Checks of model, field, and manager definitions.
    
  87. * ``security``: Checks security related configuration.
    
  88. * ``signals``: Checks on signal declarations and handler registrations.
    
  89. * ``sites``: Checks :mod:`django.contrib.sites` configuration.
    
  90. * ``staticfiles``: Checks :mod:`django.contrib.staticfiles` configuration.
    
  91. * ``templates``: Checks template related configuration.
    
  92. * ``translation``: Checks translation related configuration.
    
  93. * ``urls``: Checks URL configuration.
    
  94. 
    
  95. Some checks may be registered with multiple tags.
    
  96. 
    
  97. .. versionchanged:: 4.0
    
  98. 
    
  99.     The ``files`` tag was added.
    
  100. 
    
  101. Core system checks
    
  102. ==================
    
  103. 
    
  104. Asynchronous support
    
  105. --------------------
    
  106. 
    
  107. The following checks verify your setup for :doc:`/topics/async`:
    
  108. 
    
  109. * **async.E001**: You should not set the :envvar:`DJANGO_ALLOW_ASYNC_UNSAFE`
    
  110.   environment variable in deployment. This disables :ref:`async safety
    
  111.   protection <async-safety>`.
    
  112. 
    
  113. Backwards compatibility
    
  114. -----------------------
    
  115. 
    
  116. Compatibility checks warn of potential problems that might occur after
    
  117. upgrading Django.
    
  118. 
    
  119. * **2_0.W001**: Your URL pattern ``<pattern>`` has a ``route`` that contains
    
  120.   ``(?P<``, begins with a ``^``, or ends with a ``$``. This was likely an
    
  121.   oversight when migrating from ``url()`` to :func:`~django.urls.path`.
    
  122. * **4_0.E001**: As of Django 4.0, the values in the
    
  123.   :setting:`CSRF_TRUSTED_ORIGINS` setting must start with a scheme (usually
    
  124.   ``http://`` or ``https://``) but found ``<hostname>``.
    
  125. 
    
  126. Caches
    
  127. ------
    
  128. 
    
  129. The following checks verify that your :setting:`CACHES` setting is correctly
    
  130. configured:
    
  131. 
    
  132. * **caches.E001**: You must define a ``'default'`` cache in your
    
  133.   :setting:`CACHES` setting.
    
  134. * **caches.W002**: Your ``<cache>`` configuration might expose your cache or
    
  135.   lead to corruption of your data because its
    
  136.   :setting:`LOCATION <CACHES-LOCATION>` matches/is inside/contains
    
  137.   :setting:`MEDIA_ROOT`/:setting:`STATIC_ROOT`/:setting:`STATICFILES_DIRS`.
    
  138. * **caches.W003**: Your ``<cache>`` cache :setting:`LOCATION <CACHES-LOCATION>`
    
  139.   is relative. Use an absolute path instead.
    
  140. 
    
  141. Database
    
  142. --------
    
  143. 
    
  144. MySQL and MariaDB
    
  145. ~~~~~~~~~~~~~~~~~
    
  146. 
    
  147. If you're using MySQL or MariaDB, the following checks will be performed:
    
  148. 
    
  149. * **mysql.E001**: MySQL/MariaDB does not allow unique ``CharField``\s to have a
    
  150.   ``max_length`` > 255. *This check was changed to* ``mysql.W003`` *in Django
    
  151.   3.1 as the real maximum size depends on many factors.*
    
  152. * **mysql.W002**: MySQL/MariaDB Strict Mode is not set for database connection
    
  153.   ``<alias>``. See also :ref:`mysql-sql-mode`.
    
  154. * **mysql.W003**: MySQL/MariaDB may not allow unique ``CharField``\s to have a
    
  155.   ``max_length`` > 255.
    
  156. 
    
  157. Managing files
    
  158. --------------
    
  159. 
    
  160. .. versionadded:: 4.0
    
  161. 
    
  162. The following checks verify your setup for :doc:`/topics/files`:
    
  163. 
    
  164. * **files.E001**: The :setting:`FILE_UPLOAD_TEMP_DIR` setting refers to the
    
  165.   nonexistent directory ``<path>``.
    
  166. 
    
  167. Model fields
    
  168. ------------
    
  169. 
    
  170. * **fields.E001**: Field names must not end with an underscore.
    
  171. * **fields.E002**: Field names must not contain ``"__"``.
    
  172. * **fields.E003**: ``pk`` is a reserved word that cannot be used as a field
    
  173.   name.
    
  174. * **fields.E004**: ``choices`` must be an iterable (e.g., a list or tuple).
    
  175. * **fields.E005**: ``choices`` must be an iterable containing ``(actual value,
    
  176.   human readable name)`` tuples.
    
  177. * **fields.E006**: ``db_index`` must be ``None``, ``True`` or ``False``.
    
  178. * **fields.E007**: Primary keys must not have ``null=True``.
    
  179. * **fields.E008**: All ``validators`` must be callable.
    
  180. * **fields.E009**: ``max_length`` is too small to fit the longest value in
    
  181.   ``choices`` (``<count>`` characters).
    
  182. * **fields.E010**: ``<field>`` default should be a callable instead of an
    
  183.   instance so that it's not shared between all field instances.
    
  184. * **fields.E100**: ``AutoField``\s must set primary_key=True.
    
  185. * **fields.E110**: ``BooleanField``\s do not accept null values. *This check
    
  186.   appeared before support for null values was added in Django 2.1.*
    
  187. * **fields.E120**: ``CharField``\s must define a ``max_length`` attribute.
    
  188. * **fields.E121**: ``max_length`` must be a positive integer.
    
  189. * **fields.W122**: ``max_length`` is ignored when used with
    
  190.   ``<integer field type>``.
    
  191. * **fields.E130**: ``DecimalField``\s must define a ``decimal_places`` attribute.
    
  192. * **fields.E131**: ``decimal_places`` must be a non-negative integer.
    
  193. * **fields.E132**: ``DecimalField``\s must define a ``max_digits`` attribute.
    
  194. * **fields.E133**: ``max_digits`` must be a positive integer.
    
  195. * **fields.E134**: ``max_digits`` must be greater or equal to ``decimal_places``.
    
  196. * **fields.E140**: ``FilePathField``\s must have either ``allow_files`` or
    
  197.   ``allow_folders`` set to True.
    
  198. * **fields.E150**: ``GenericIPAddressField``\s cannot have ``blank=True`` if
    
  199.   ``null=False``, as blank values are stored as nulls.
    
  200. * **fields.E160**: The options ``auto_now``, ``auto_now_add``, and ``default``
    
  201.   are mutually exclusive. Only one of these options may be present.
    
  202. * **fields.W161**: Fixed default value provided.
    
  203. * **fields.W162**: ``<database>`` does not support a database index on
    
  204.   ``<field data type>`` columns.
    
  205. * **fields.E170**: ``BinaryField``’s ``default`` cannot be a string. Use bytes
    
  206.   content instead.
    
  207. * **fields.E180**: ``<database>`` does not support ``JSONField``\s.
    
  208. * **fields.E190**: ``<database>`` does not support a database collation on
    
  209.   ``<field_type>``\s.
    
  210. * **fields.E900**: ``IPAddressField`` has been removed except for support in
    
  211.   historical migrations.
    
  212. * **fields.W900**: ``IPAddressField`` has been deprecated. Support for it
    
  213.   (except in historical migrations) will be removed in Django 1.9. *This check
    
  214.   appeared in Django 1.7 and 1.8*.
    
  215. * **fields.W901**: ``CommaSeparatedIntegerField`` has been deprecated. Support
    
  216.   for it (except in historical migrations) will be removed in Django 2.0. *This
    
  217.   check appeared in Django 1.10 and 1.11*.
    
  218. * **fields.E901**: ``CommaSeparatedIntegerField`` is removed except for support
    
  219.   in historical migrations.
    
  220. * **fields.W902**: ``FloatRangeField`` is deprecated and will be removed in
    
  221.   Django 3.1. *This check appeared in Django 2.2 and 3.0*.
    
  222. * **fields.W903**: ``NullBooleanField`` is deprecated. Support for it (except
    
  223.   in historical migrations) will be removed in Django 4.0. *This check appeared
    
  224.   in Django 3.1 and 3.2*.
    
  225. * **fields.E903**: ``NullBooleanField`` is removed except for support in
    
  226.   historical migrations.
    
  227. * **fields.W904**: ``django.contrib.postgres.fields.JSONField`` is deprecated.
    
  228.   Support for it (except in historical migrations) will be removed in Django
    
  229.   4.0. *This check appeared in Django 3.1 and 3.2*.
    
  230. * **fields.E904**: ``django.contrib.postgres.fields.JSONField`` is removed
    
  231.   except for support in historical migrations.
    
  232. 
    
  233. File fields
    
  234. ~~~~~~~~~~~
    
  235. 
    
  236. * **fields.E200**: ``unique`` is not a valid argument for a ``FileField``.
    
  237.   *This check is removed in Django 1.11*.
    
  238. * **fields.E201**: ``primary_key`` is not a valid argument for a ``FileField``.
    
  239. * **fields.E202**: ``FileField``’s ``upload_to`` argument must be a relative
    
  240.   path, not an absolute path.
    
  241. * **fields.E210**: Cannot use ``ImageField`` because Pillow is not installed.
    
  242. 
    
  243. Related fields
    
  244. ~~~~~~~~~~~~~~
    
  245. 
    
  246. * **fields.E300**: Field defines a relation with model ``<model>``, which is
    
  247.   either not installed, or is abstract.
    
  248. * **fields.E301**: Field defines a relation with the model
    
  249.   ``<app_label>.<model>`` which has been swapped out.
    
  250. * **fields.E302**: Reverse accessor ``<related model>.<accessor name>`` for
    
  251.   ``<app_label>.<model>.<field name>`` clashes with field name
    
  252.   ``<app_label>.<model>.<field name>``.
    
  253. * **fields.E303**: Reverse query name for ``<app_label>.<model>.<field name>``
    
  254.   clashes with field name ``<app_label>.<model>.<field name>``.
    
  255. * **fields.E304**: Reverse accessor ``<related model>.<accessor name>`` for
    
  256.   ``<app_label>.<model>.<field name>`` clashes with reverse accessor for
    
  257.   ``<app_label>.<model>.<field name>``.
    
  258. * **fields.E305**: Reverse query name for ``<app_label>.<model>.<field name>``
    
  259.   clashes with reverse query name for ``<app_label>.<model>.<field name>``.
    
  260. * **fields.E306**: The name ``<name>`` is invalid ``related_name`` for field
    
  261.   ``<model>.<field name>``.
    
  262. * **fields.E307**: The field ``<app label>.<model>.<field name>`` was declared
    
  263.   with a lazy reference to ``<app label>.<model>``, but app ``<app label>``
    
  264.   isn't installed or doesn't provide model ``<model>``.
    
  265. * **fields.E308**: Reverse query name ``<related query name>`` must not end
    
  266.   with an underscore.
    
  267. * **fields.E309**: Reverse query name ``<related query name>`` must not contain
    
  268.   ``'__'``.
    
  269. * **fields.E310**: No subset of the fields ``<field1>``, ``<field2>``, ... on
    
  270.   model ``<model>`` is unique.
    
  271. * **fields.E311**: ``<model>.<field name>`` must be unique because it is
    
  272.   referenced by a ``ForeignKey``.
    
  273. * **fields.E312**: The ``to_field`` ``<field name>`` doesn't exist on the
    
  274.   related model ``<app label>.<model>``.
    
  275. * **fields.E320**: Field specifies ``on_delete=SET_NULL``, but cannot be null.
    
  276. * **fields.E321**: The field specifies ``on_delete=SET_DEFAULT``, but has no
    
  277.   default value.
    
  278. * **fields.E330**: ``ManyToManyField``\s cannot be unique.
    
  279. * **fields.E331**: Field specifies a many-to-many relation through model
    
  280.   ``<model>``, which has not been installed.
    
  281. * **fields.E332**: Many-to-many fields with intermediate tables must not be
    
  282.   symmetrical. *This check appeared before Django 3.0.*
    
  283. * **fields.E333**: The model is used as an intermediate model by ``<model>``,
    
  284.   but it has more than two foreign keys to ``<model>``, which is ambiguous.
    
  285.   You must specify which two foreign keys Django should use via the
    
  286.   ``through_fields`` keyword argument.
    
  287. * **fields.E334**: The model is used as an intermediate model by ``<model>``,
    
  288.   but it has more than one foreign key from ``<model>``, which is ambiguous.
    
  289.   You must specify which foreign key Django should use via the
    
  290.   ``through_fields`` keyword argument.
    
  291. * **fields.E335**: The model is used as an intermediate model by ``<model>``,
    
  292.   but it has more than one foreign key to ``<model>``, which is ambiguous.
    
  293.   You must specify which foreign key Django should use via the
    
  294.   ``through_fields`` keyword argument.
    
  295. * **fields.E336**: The model is used as an intermediary model by ``<model>``,
    
  296.   but it does not have foreign key to ``<model>`` or ``<model>``.
    
  297. * **fields.E337**: Field specifies ``through_fields`` but does not provide the
    
  298.   names of the two link fields that should be used for the relation through
    
  299.   ``<model>``.
    
  300. * **fields.E338**: The intermediary model ``<through model>`` has no field
    
  301.   ``<field name>``.
    
  302. * **fields.E339**: ``<model>.<field name>`` is not a foreign key to ``<model>``.
    
  303. * **fields.E340**: The field's intermediary table ``<table name>`` clashes with
    
  304.   the table name of ``<model>``/``<model>.<field name>``.
    
  305. * **fields.W340**: ``null`` has no effect on ``ManyToManyField``.
    
  306. * **fields.W341**: ``ManyToManyField`` does not support ``validators``.
    
  307. * **fields.W342**: Setting ``unique=True`` on a ``ForeignKey`` has the same
    
  308.   effect as using a ``OneToOneField``.
    
  309. * **fields.W343**: ``limit_choices_to`` has no effect on ``ManyToManyField``
    
  310.   with a ``through`` model. *This check appeared before Django 4.0.*
    
  311. * **fields.W344**: The field's intermediary table ``<table name>`` clashes with
    
  312.   the table name of ``<model>``/``<model>.<field name>``.
    
  313. * **fields.W345**: ``related_name`` has no effect on ``ManyToManyField`` with a
    
  314.   symmetrical relationship, e.g. to "self".
    
  315. 
    
  316. Models
    
  317. ------
    
  318. 
    
  319. * **models.E001**: ``<swappable>`` is not of the form ``app_label.app_name``.
    
  320. * **models.E002**: ``<SETTING>`` references ``<model>``, which has not been
    
  321.   installed, or is abstract.
    
  322. * **models.E003**: The model has two identical many-to-many relations through
    
  323.   the intermediate model ``<app_label>.<model>``.
    
  324. * **models.E004**: ``id`` can only be used as a field name if the field also
    
  325.   sets ``primary_key=True``.
    
  326. * **models.E005**: The field ``<field name>`` from parent model ``<model>``
    
  327.   clashes with the field ``<field name>`` from parent model ``<model>``.
    
  328. * **models.E006**: The field ``<field name>`` clashes with the field
    
  329.   ``<field name>`` from model ``<model>``.
    
  330. * **models.E007**: Field ``<field name>`` has column name ``<column name>``
    
  331.   that is used by another field.
    
  332. * **models.E008**: ``index_together`` must be a list or tuple.
    
  333. * **models.E009**: All ``index_together`` elements must be lists or tuples.
    
  334. * **models.E010**: ``unique_together`` must be a list or tuple.
    
  335. * **models.E011**: All ``unique_together`` elements must be lists or tuples.
    
  336. * **models.E012**: ``constraints/indexes/index_together/unique_together``
    
  337.   refers to the nonexistent field ``<field name>``.
    
  338. * **models.E013**: ``constraints/indexes/index_together/unique_together``
    
  339.   refers to a ``ManyToManyField`` ``<field name>``, but ``ManyToManyField``\s
    
  340.   are not supported for that option.
    
  341. * **models.E014**: ``ordering`` must be a tuple or list (even if you want to
    
  342.   order by only one field).
    
  343. * **models.E015**: ``ordering`` refers to the nonexistent field, related field,
    
  344.   or lookup ``<field name>``.
    
  345. * **models.E016**: ``constraints/indexes/index_together/unique_together``
    
  346.   refers to field ``<field_name>`` which is not local to model ``<model>``.
    
  347. * **models.E017**: Proxy model ``<model>`` contains model fields.
    
  348. * **models.E018**: Autogenerated column name too long for field ``<field>``.
    
  349.   Maximum length is ``<maximum length>`` for database ``<alias>``.
    
  350. * **models.E019**: Autogenerated column name too long for M2M field
    
  351.   ``<M2M field>``. Maximum length is ``<maximum length>`` for database
    
  352.   ``<alias>``.
    
  353. * **models.E020**: The ``<model>.check()`` class method is currently overridden.
    
  354. * **models.E021**: ``ordering`` and ``order_with_respect_to`` cannot be used
    
  355.   together.
    
  356. * **models.E022**: ``<function>`` contains a lazy reference to
    
  357.   ``<app label>.<model>``, but app ``<app label>`` isn't installed or
    
  358.   doesn't provide model ``<model>``.
    
  359. * **models.E023**: The model name ``<model>`` cannot start or end with an
    
  360.   underscore as it collides with the query lookup syntax.
    
  361. * **models.E024**: The model name ``<model>`` cannot contain double underscores
    
  362.   as it collides with the query lookup syntax.
    
  363. * **models.E025**: The property ``<property name>`` clashes with a related
    
  364.   field accessor.
    
  365. * **models.E026**: The model cannot have more than one field with
    
  366.   ``primary_key=True``.
    
  367. * **models.W027**: ``<database>`` does not support check constraints.
    
  368. * **models.E028**: ``db_table`` ``<db_table>`` is used by multiple models:
    
  369.   ``<model list>``.
    
  370. * **models.E029**: index name ``<index>`` is not unique for model ``<model>``.
    
  371. * **models.E030**: index name ``<index>`` is not unique among models:
    
  372.   ``<model list>``.
    
  373. * **models.E031**: constraint name ``<constraint>`` is not unique for model
    
  374.   ``<model>``.
    
  375. * **models.E032**: constraint name ``<constraint>`` is not unique among
    
  376.   models: ``<model list>``.
    
  377. * **models.E033**: The index name ``<index>`` cannot start with an underscore
    
  378.   or a number.
    
  379. * **models.E034**: The index name ``<index>`` cannot be longer than
    
  380.   ``<max_length>`` characters.
    
  381. * **models.W035**: ``db_table`` ``<db_table>`` is used by multiple models:
    
  382.   ``<model list>``.
    
  383. * **models.W036**: ``<database>`` does not support unique constraints with
    
  384.   conditions.
    
  385. * **models.W037**: ``<database>`` does not support indexes with conditions.
    
  386. * **models.W038**: ``<database>`` does not support deferrable unique
    
  387.   constraints.
    
  388. * **models.W039**: ``<database>`` does not support unique constraints with
    
  389.   non-key columns.
    
  390. * **models.W040**: ``<database>`` does not support indexes with non-key
    
  391.   columns.
    
  392. * **models.E041**: ``constraints`` refers to the joined field ``<field name>``.
    
  393. * **models.W042**: Auto-created primary key used when not defining a primary
    
  394.   key type, by default ``django.db.models.AutoField``.
    
  395. * **models.W043**: ``<database>`` does not support indexes on expressions.
    
  396. * **models.W044**: ``<database>`` does not support unique constraints on
    
  397.   expressions.
    
  398. * **models.W045**: Check constraint ``<constraint>`` contains ``RawSQL()``
    
  399.   expression and won't be validated during the model ``full_clean()``.
    
  400. 
    
  401. Security
    
  402. --------
    
  403. 
    
  404. The security checks do not make your site secure. They do not audit code, do
    
  405. intrusion detection, or do anything particularly complex. Rather, they help
    
  406. perform an automated, low-hanging-fruit checklist, that can help you to improve
    
  407. your site's security.
    
  408. 
    
  409. Some of these checks may not be appropriate for your particular deployment
    
  410. configuration. For instance, if you do your HTTP to HTTPS redirection in a load
    
  411. balancer, it'd be irritating to be constantly warned about not having enabled
    
  412. :setting:`SECURE_SSL_REDIRECT`. Use :setting:`SILENCED_SYSTEM_CHECKS` to
    
  413. silence unneeded checks.
    
  414. 
    
  415. The following checks are run if you use the :option:`check --deploy` option:
    
  416. 
    
  417. * **security.W001**: You do not have
    
  418.   :class:`django.middleware.security.SecurityMiddleware` in your
    
  419.   :setting:`MIDDLEWARE` so the :setting:`SECURE_HSTS_SECONDS`,
    
  420.   :setting:`SECURE_CONTENT_TYPE_NOSNIFF`, :setting:`SECURE_REFERRER_POLICY`,
    
  421.   :setting:`SECURE_CROSS_ORIGIN_OPENER_POLICY`, and
    
  422.   :setting:`SECURE_SSL_REDIRECT` settings will have no effect.
    
  423. * **security.W002**: You do not have
    
  424.   :class:`django.middleware.clickjacking.XFrameOptionsMiddleware` in your
    
  425.   :setting:`MIDDLEWARE`, so your pages will not be served with an
    
  426.   ``'x-frame-options'`` header. Unless there is a good reason for your
    
  427.   site to be served in a frame, you should consider enabling this
    
  428.   header to help prevent clickjacking attacks.
    
  429. * **security.W003**: You don't appear to be using Django's built-in cross-site
    
  430.   request forgery protection via the middleware
    
  431.   (:class:`django.middleware.csrf.CsrfViewMiddleware` is not in your
    
  432.   :setting:`MIDDLEWARE`). Enabling the middleware is the safest
    
  433.   approach to ensure you don't leave any holes.
    
  434. * **security.W004**: You have not set a value for the
    
  435.   :setting:`SECURE_HSTS_SECONDS` setting. If your entire site is served only
    
  436.   over SSL, you may want to consider setting a value and enabling :ref:`HTTP
    
  437.   Strict Transport Security <http-strict-transport-security>`. Be sure to read
    
  438.   the documentation first; enabling HSTS carelessly can cause serious,
    
  439.   irreversible problems.
    
  440. * **security.W005**: You have not set the
    
  441.   :setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS` setting to ``True``. Without this,
    
  442.   your site is potentially vulnerable to attack via an insecure connection to a
    
  443.   subdomain. Only set this to ``True`` if you are certain that all subdomains of
    
  444.   your domain should be served exclusively via SSL.
    
  445. * **security.W006**: Your :setting:`SECURE_CONTENT_TYPE_NOSNIFF` setting is not
    
  446.   set to ``True``, so your pages will not be served with an
    
  447.   ``'X-Content-Type-Options: nosniff'`` header. You should consider enabling
    
  448.   this header to prevent the browser from identifying content types incorrectly.
    
  449. * **security.W007**: Your ``SECURE_BROWSER_XSS_FILTER`` setting is not
    
  450.   set to ``True``, so your pages will not be served with an
    
  451.   ``'X-XSS-Protection: 1; mode=block'`` header. You should consider enabling
    
  452.   this header to activate the browser's XSS filtering and help prevent XSS
    
  453.   attacks. *This check is removed in Django 3.0 as the* ``X-XSS-Protection``
    
  454.   *header is no longer honored by modern browsers.*
    
  455. * **security.W008**: Your :setting:`SECURE_SSL_REDIRECT` setting is not set to
    
  456.   ``True``. Unless your site should be available over both SSL and non-SSL
    
  457.   connections, you may want to either set this setting to ``True`` or configure
    
  458.   a load balancer or reverse-proxy server  to redirect all connections to HTTPS.
    
  459. * **security.W009**: Your :setting:`SECRET_KEY` has less than 50 characters,
    
  460.   less than 5 unique characters, or it's prefixed with ``'django-insecure-'``
    
  461.   indicating that it was generated automatically by Django. Please generate a
    
  462.   long and random value, otherwise many of Django's security-critical features
    
  463.   will be vulnerable to attack.
    
  464. * **security.W010**: You have :mod:`django.contrib.sessions` in your
    
  465.   :setting:`INSTALLED_APPS` but you have not set
    
  466.   :setting:`SESSION_COOKIE_SECURE` to ``True``. Using a secure-only session
    
  467.   cookie makes it more difficult for network traffic sniffers to hijack user
    
  468.   sessions.
    
  469. * **security.W011**: You have
    
  470.   :class:`django.contrib.sessions.middleware.SessionMiddleware` in your
    
  471.   :setting:`MIDDLEWARE`, but you have not set :setting:`SESSION_COOKIE_SECURE`
    
  472.   to ``True``. Using a secure-only session cookie makes it more difficult for
    
  473.   network traffic sniffers to hijack user sessions.
    
  474. * **security.W012**: :setting:`SESSION_COOKIE_SECURE` is not set to ``True``.
    
  475.   Using a secure-only session cookie makes it more difficult for network traffic
    
  476.   sniffers to hijack user sessions.
    
  477. * **security.W013**: You have :mod:`django.contrib.sessions` in your
    
  478.   :setting:`INSTALLED_APPS`, but you have not set
    
  479.   :setting:`SESSION_COOKIE_HTTPONLY` to ``True``. Using an ``HttpOnly`` session
    
  480.   cookie makes it more difficult for cross-site scripting attacks to hijack user
    
  481.   sessions.
    
  482. * **security.W014**: You have
    
  483.   :class:`django.contrib.sessions.middleware.SessionMiddleware` in your
    
  484.   :setting:`MIDDLEWARE`, but you have not set :setting:`SESSION_COOKIE_HTTPONLY`
    
  485.   to ``True``. Using an ``HttpOnly`` session cookie makes it more difficult for
    
  486.   cross-site scripting attacks to hijack user sessions.
    
  487. * **security.W015**: :setting:`SESSION_COOKIE_HTTPONLY` is not set to ``True``.
    
  488.   Using an ``HttpOnly`` session cookie makes it more difficult for cross-site
    
  489.   scripting attacks to hijack user sessions.
    
  490. * **security.W016**: :setting:`CSRF_COOKIE_SECURE` is not set to ``True``.
    
  491.   Using a secure-only CSRF cookie makes it more difficult for network traffic
    
  492.   sniffers to steal the CSRF token.
    
  493. * **security.W017**: :setting:`CSRF_COOKIE_HTTPONLY` is not set to ``True``.
    
  494.   Using an ``HttpOnly`` CSRF cookie makes it more difficult for cross-site
    
  495.   scripting attacks to steal the CSRF token. *This check is removed in Django
    
  496.   1.11 as the* :setting:`CSRF_COOKIE_HTTPONLY` *setting offers no practical
    
  497.   benefit.*
    
  498. * **security.W018**: You should not have :setting:`DEBUG` set to ``True`` in
    
  499.   deployment.
    
  500. * **security.W019**: You have
    
  501.   :class:`django.middleware.clickjacking.XFrameOptionsMiddleware` in your
    
  502.   :setting:`MIDDLEWARE`, but :setting:`X_FRAME_OPTIONS` is not set to
    
  503.   ``'DENY'``. Unless there is a good reason for your site to serve other parts
    
  504.   of itself in a frame, you should change it to ``'DENY'``.
    
  505. * **security.W020**: :setting:`ALLOWED_HOSTS` must not be empty in deployment.
    
  506. * **security.W021**: You have not set the
    
  507.   :setting:`SECURE_HSTS_PRELOAD` setting to ``True``. Without this, your site
    
  508.   cannot be submitted to the browser preload list.
    
  509. * **security.W022**: You have not set the :setting:`SECURE_REFERRER_POLICY`
    
  510.   setting. Without this, your site will not send a Referrer-Policy header. You
    
  511.   should consider enabling this header to protect user privacy.
    
  512. * **security.E023**: You have set the :setting:`SECURE_REFERRER_POLICY` setting
    
  513.   to an invalid value.
    
  514. * **security.E024**: You have set the
    
  515.   :setting:`SECURE_CROSS_ORIGIN_OPENER_POLICY` setting to an invalid value.
    
  516. * **security.W025**: Your
    
  517.   :setting:`SECRET_KEY_FALLBACKS[n] <SECRET_KEY_FALLBACKS>` has less than 50
    
  518.   characters, less than 5 unique characters, or it's prefixed with
    
  519.   ``'django-insecure-'`` indicating that it was generated automatically by
    
  520.   Django. Please generate a long and random value, otherwise many of Django's
    
  521.   security-critical features will be vulnerable to attack.
    
  522. 
    
  523. The following checks verify that your security-related settings are correctly
    
  524. configured:
    
  525. 
    
  526. * **security.E100**: ``DEFAULT_HASHING_ALGORITHM`` must be ``'sha1'`` or
    
  527.   ``'sha256'``. *This check appeared in Django 3.1 and 3.2*.
    
  528. * **security.E101**: The CSRF failure view ``'path.to.view'`` does not take the
    
  529.   correct number of arguments.
    
  530. * **security.E102**: The CSRF failure view ``'path.to.view'`` could not be
    
  531.   imported.
    
  532. 
    
  533. Signals
    
  534. -------
    
  535. 
    
  536. * **signals.E001**: ``<handler>`` was connected to the ``<signal>`` signal with
    
  537.   a lazy reference to the sender ``<app label>.<model>``, but app ``<app label>``
    
  538.   isn't installed or doesn't provide model ``<model>``.
    
  539. 
    
  540. Templates
    
  541. ---------
    
  542. 
    
  543. The following checks verify that your :setting:`TEMPLATES` setting is correctly
    
  544. configured:
    
  545. 
    
  546. * **templates.E001**: You have ``'APP_DIRS': True`` in your
    
  547.   :setting:`TEMPLATES` but also specify ``'loaders'`` in ``OPTIONS``. Either
    
  548.   remove ``APP_DIRS`` or remove the ``'loaders'`` option.
    
  549. * **templates.E002**: ``string_if_invalid`` in :setting:`TEMPLATES`
    
  550.   :setting:`OPTIONS <TEMPLATES-OPTIONS>` must be a string but got: ``{value}``
    
  551.   (``{type}``).
    
  552. * **templates.E003**:``<name>`` is used for multiple template tag modules:
    
  553.   ``<module list>``. *This check was changed to* ``templates.W003`` *in Django
    
  554.   4.1.2*.
    
  555. * **templates.W003**:``<name>`` is used for multiple template tag modules:
    
  556.   ``<module list>``.
    
  557. 
    
  558. Translation
    
  559. -----------
    
  560. 
    
  561. The following checks are performed on your translation configuration:
    
  562. 
    
  563. * **translation.E001**: You have provided an invalid value for the
    
  564.   :setting:`LANGUAGE_CODE` setting: ``<value>``.
    
  565. * **translation.E002**: You have provided an invalid language code in the
    
  566.   :setting:`LANGUAGES` setting: ``<value>``.
    
  567. * **translation.E003**: You have provided an invalid language code in the
    
  568.   :setting:`LANGUAGES_BIDI` setting: ``<value>``.
    
  569. * **translation.E004**: You have provided a value for the
    
  570.   :setting:`LANGUAGE_CODE` setting that is not in the :setting:`LANGUAGES`
    
  571.   setting.
    
  572. 
    
  573. URLs
    
  574. ----
    
  575. 
    
  576. The following checks are performed on your URL configuration:
    
  577. 
    
  578. * **urls.W001**: Your URL pattern ``<pattern>`` uses
    
  579.   :func:`~django.urls.include` with a ``route`` ending with a ``$``. Remove the
    
  580.   dollar from the ``route`` to avoid problems including URLs.
    
  581. * **urls.W002**: Your URL pattern ``<pattern>`` has a ``route`` beginning with
    
  582.   a ``/``. Remove this slash as it is unnecessary. If this pattern is targeted
    
  583.   in an :func:`~django.urls.include`, ensure the :func:`~django.urls.include`
    
  584.   pattern has a trailing ``/``.
    
  585. * **urls.W003**: Your URL pattern ``<pattern>`` has a ``name``
    
  586.   including a ``:``. Remove the colon, to avoid ambiguous namespace
    
  587.   references.
    
  588. * **urls.E004**: Your URL pattern ``<pattern>`` is invalid. Ensure that
    
  589.   ``urlpatterns`` is a list of :func:`~django.urls.path` and/or
    
  590.   :func:`~django.urls.re_path` instances.
    
  591. * **urls.W005**: URL namespace ``<namespace>`` isn't unique. You may not be
    
  592.   able to reverse all URLs in this namespace.
    
  593. * **urls.E006**: The :setting:`MEDIA_URL`/ :setting:`STATIC_URL` setting must
    
  594.   end with a slash.
    
  595. * **urls.E007**: The custom ``handlerXXX`` view ``'path.to.view'`` does not
    
  596.   take the correct number of arguments (…).
    
  597. * **urls.E008**: The custom ``handlerXXX`` view ``'path.to.view'`` could not be
    
  598.   imported.
    
  599. * **urls.E009**: Your URL pattern ``<pattern>`` has an invalid view, pass
    
  600.   ``<view>.as_view()`` instead of ``<view>``.
    
  601. 
    
  602. ``contrib`` app checks
    
  603. ======================
    
  604. 
    
  605. ``admin``
    
  606. ---------
    
  607. 
    
  608. Admin checks are all performed as part of the ``admin`` tag.
    
  609. 
    
  610. The following checks are performed on any
    
  611. :class:`~django.contrib.admin.ModelAdmin` (or subclass) that is registered
    
  612. with the admin site:
    
  613. 
    
  614. * **admin.E001**: The value of ``raw_id_fields`` must be a list or tuple.
    
  615. * **admin.E002**: The value of ``raw_id_fields[n]`` refers to ``<field name>``,
    
  616.   which is not a field of ``<model>``.
    
  617. * **admin.E003**: The value of ``raw_id_fields[n]`` must be a foreign key or
    
  618.   a many-to-many field.
    
  619. * **admin.E004**: The value of ``fields`` must be a list or tuple.
    
  620. * **admin.E005**: Both ``fieldsets`` and ``fields`` are specified.
    
  621. * **admin.E006**: The value of ``fields`` contains duplicate field(s).
    
  622. * **admin.E007**: The value of ``fieldsets`` must be a list or tuple.
    
  623. * **admin.E008**: The value of ``fieldsets[n]`` must be a list or tuple.
    
  624. * **admin.E009**: The value of ``fieldsets[n]`` must be of length 2.
    
  625. * **admin.E010**: The value of ``fieldsets[n][1]`` must be a dictionary.
    
  626. * **admin.E011**: The value of ``fieldsets[n][1]`` must contain the key
    
  627.   ``fields``.
    
  628. * **admin.E012**: There are duplicate field(s) in ``fieldsets[n][1]``.
    
  629. * **admin.E013**: ``fields[n]/fieldsets[n][m]`` cannot include the
    
  630.   ``ManyToManyField`` ``<field name>``, because that field manually specifies a
    
  631.   relationship model.
    
  632. * **admin.E014**: The value of ``exclude`` must be a list or tuple.
    
  633. * **admin.E015**: The value of ``exclude`` contains duplicate field(s).
    
  634. * **admin.E016**: The value of ``form`` must inherit from ``BaseModelForm``.
    
  635. * **admin.E017**: The value of ``filter_vertical`` must be a list or tuple.
    
  636. * **admin.E018**: The value of ``filter_horizontal`` must be a list or tuple.
    
  637. * **admin.E019**: The value of ``filter_vertical[n]/filter_horizontal[n]``
    
  638.   refers to ``<field name>``, which is not a field of ``<model>``.
    
  639. * **admin.E020**: The value of ``filter_vertical[n]/filter_horizontal[n]``
    
  640.   must be a many-to-many field.
    
  641. * **admin.E021**: The value of ``radio_fields`` must be a dictionary.
    
  642. * **admin.E022**: The value of ``radio_fields`` refers to ``<field name>``,
    
  643.   which is not a field of ``<model>``.
    
  644. * **admin.E023**: The value of ``radio_fields`` refers to ``<field name>``,
    
  645.   which is not an instance of ``ForeignKey``, and does not have a ``choices``
    
  646.   definition.
    
  647. * **admin.E024**: The value of ``radio_fields[<field name>]`` must be either
    
  648.   ``admin.HORIZONTAL`` or ``admin.VERTICAL``.
    
  649. * **admin.E025**: The value of ``view_on_site`` must be either a callable or a
    
  650.   boolean value.
    
  651. * **admin.E026**: The value of ``prepopulated_fields`` must be a dictionary.
    
  652. * **admin.E027**: The value of ``prepopulated_fields`` refers to
    
  653.   ``<field name>``, which is not a field of ``<model>``.
    
  654. * **admin.E028**: The value of ``prepopulated_fields`` refers to
    
  655.   ``<field name>``, which must not be a ``DateTimeField``, a ``ForeignKey``,
    
  656.   a ``OneToOneField``, or a ``ManyToManyField`` field.
    
  657. * **admin.E029**: The value of ``prepopulated_fields[<field name>]`` must be a
    
  658.   list or tuple.
    
  659. * **admin.E030**: The value of ``prepopulated_fields`` refers to
    
  660.   ``<field name>``, which is not a field of ``<model>``.
    
  661. * **admin.E031**: The value of ``ordering`` must be a list or tuple.
    
  662. * **admin.E032**: The value of ``ordering`` has the random ordering marker
    
  663.   ``?``, but contains other fields as well.
    
  664. * **admin.E033**: The value of ``ordering`` refers to ``<field name>``, which
    
  665.   is not a field of ``<model>``.
    
  666. * **admin.E034**: The value of ``readonly_fields`` must be a list or tuple.
    
  667. * **admin.E035**: The value of ``readonly_fields[n]`` is not a callable, an
    
  668.   attribute of ``<ModelAdmin class>``, or an attribute of ``<model>``.
    
  669. * **admin.E036**: The value of ``autocomplete_fields`` must be a list or tuple.
    
  670. * **admin.E037**: The value of ``autocomplete_fields[n]`` refers to
    
  671.   ``<field name>``, which is not a field of ``<model>``.
    
  672. * **admin.E038**: The value of ``autocomplete_fields[n]`` must be a foreign
    
  673.   key or a many-to-many field.
    
  674. * **admin.E039**: An admin for model ``<model>`` has to be registered to be
    
  675.   referenced by ``<modeladmin>.autocomplete_fields``.
    
  676. * **admin.E040**: ``<modeladmin>`` must define ``search_fields``, because
    
  677.   it's referenced by ``<other_modeladmin>.autocomplete_fields``.
    
  678. 
    
  679. ``ModelAdmin``
    
  680. ~~~~~~~~~~~~~~
    
  681. 
    
  682. The following checks are performed on any
    
  683. :class:`~django.contrib.admin.ModelAdmin` that is registered
    
  684. with the admin site:
    
  685. 
    
  686. * **admin.E101**: The value of ``save_as`` must be a boolean.
    
  687. * **admin.E102**: The value of ``save_on_top`` must be a boolean.
    
  688. * **admin.E103**: The value of ``inlines`` must be a list or tuple.
    
  689. * **admin.E104**: ``<InlineModelAdmin class>`` must inherit from
    
  690.   ``InlineModelAdmin``.
    
  691. * **admin.E105**: ``<InlineModelAdmin class>`` must have a ``model`` attribute.
    
  692. * **admin.E106**: The value of ``<InlineModelAdmin class>.model`` must be a
    
  693.   ``Model``.
    
  694. * **admin.E107**: The value of ``list_display`` must be a list or tuple.
    
  695. * **admin.E108**: The value of ``list_display[n]`` refers to ``<label>``,
    
  696.   which is not a callable, an attribute of ``<ModelAdmin class>``, or an
    
  697.   attribute or method on ``<model>``.
    
  698. * **admin.E109**: The value of ``list_display[n]`` must not be a
    
  699.   ``ManyToManyField`` field.
    
  700. * **admin.E110**: The value of ``list_display_links`` must be a list, a tuple,
    
  701.   or ``None``.
    
  702. * **admin.E111**: The value of ``list_display_links[n]`` refers to ``<label>``,
    
  703.   which is not defined in ``list_display``.
    
  704. * **admin.E112**: The value of ``list_filter`` must be a list or tuple.
    
  705. * **admin.E113**: The value of ``list_filter[n]`` must inherit from
    
  706.   ``ListFilter``.
    
  707. * **admin.E114**: The value of ``list_filter[n]`` must not inherit from
    
  708.   ``FieldListFilter``.
    
  709. * **admin.E115**: The value of ``list_filter[n][1]`` must inherit from
    
  710.   ``FieldListFilter``.
    
  711. * **admin.E116**: The value of ``list_filter[n]`` refers to ``<label>``,
    
  712.   which does not refer to a Field.
    
  713. * **admin.E117**: The value of ``list_select_related`` must be a boolean,
    
  714.   tuple or list.
    
  715. * **admin.E118**: The value of ``list_per_page`` must be an integer.
    
  716. * **admin.E119**: The value of ``list_max_show_all`` must be an integer.
    
  717. * **admin.E120**: The value of ``list_editable`` must be a list or tuple.
    
  718. * **admin.E121**: The value of ``list_editable[n]`` refers to ``<label>``,
    
  719.   which is not a field of ``<model>``.
    
  720. * **admin.E122**: The value of ``list_editable[n]`` refers to ``<label>``,
    
  721.   which is not contained in ``list_display``.
    
  722. * **admin.E123**: The value of ``list_editable[n]`` cannot be in both
    
  723.   ``list_editable`` and ``list_display_links``.
    
  724. * **admin.E124**: The value of ``list_editable[n]`` refers to the first field
    
  725.   in ``list_display`` (``<label>``), which cannot be used unless
    
  726.   ``list_display_links`` is set.
    
  727. * **admin.E125**: The value of ``list_editable[n]`` refers to ``<field name>``,
    
  728.   which is not editable through the admin.
    
  729. * **admin.E126**: The value of ``search_fields`` must be a list or tuple.
    
  730. * **admin.E127**: The value of ``date_hierarchy`` refers to ``<field name>``,
    
  731.   which does not refer to a Field.
    
  732. * **admin.E128**: The value of ``date_hierarchy`` must be a ``DateField`` or
    
  733.   ``DateTimeField``.
    
  734. * **admin.E129**: ``<modeladmin>`` must define a ``has_<foo>_permission()``
    
  735.   method for the ``<action>`` action.
    
  736. * **admin.E130**: ``__name__`` attributes of actions defined in
    
  737.   ``<modeladmin>`` must be unique. Name ``<name>`` is not unique.
    
  738. 
    
  739. ``InlineModelAdmin``
    
  740. ~~~~~~~~~~~~~~~~~~~~
    
  741. 
    
  742. The following checks are performed on any
    
  743. :class:`~django.contrib.admin.InlineModelAdmin` that is registered as an
    
  744. inline on a :class:`~django.contrib.admin.ModelAdmin`.
    
  745. 
    
  746. * **admin.E201**: Cannot exclude the field ``<field name>``, because it is the
    
  747.   foreign key to the parent model ``<app_label>.<model>``.
    
  748. * **admin.E202**: ``<model>`` has no ``ForeignKey`` to ``<parent model>``./
    
  749.   ``<model>`` has more than one ``ForeignKey`` to ``<parent model>``. You must
    
  750.   specify a ``fk_name`` attribute.
    
  751. * **admin.E203**: The value of ``extra`` must be an integer.
    
  752. * **admin.E204**: The value of ``max_num`` must be an integer.
    
  753. * **admin.E205**: The value of ``min_num`` must be an integer.
    
  754. * **admin.E206**: The value of ``formset`` must inherit from
    
  755.   ``BaseModelFormSet``.
    
  756. 
    
  757. ``GenericInlineModelAdmin``
    
  758. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  759. 
    
  760. The following checks are performed on any
    
  761. :class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin` that is
    
  762. registered as an inline on a :class:`~django.contrib.admin.ModelAdmin`.
    
  763. 
    
  764. * **admin.E301**: ``'ct_field'`` references ``<label>``, which is not a field
    
  765.   on ``<model>``.
    
  766. * **admin.E302**: ``'ct_fk_field'`` references ``<label>``, which is not a
    
  767.   field on ``<model>``.
    
  768. * **admin.E303**: ``<model>`` has no ``GenericForeignKey``.
    
  769. * **admin.E304**: ``<model>`` has no ``GenericForeignKey`` using content type
    
  770.   field ``<field name>`` and object ID field ``<field name>``.
    
  771. 
    
  772. ``AdminSite``
    
  773. ~~~~~~~~~~~~~
    
  774. 
    
  775. The following checks are performed on the default
    
  776. :class:`~django.contrib.admin.AdminSite`:
    
  777. 
    
  778. * **admin.E401**: :mod:`django.contrib.contenttypes` must be in
    
  779.   :setting:`INSTALLED_APPS` in order to use the admin application.
    
  780. * **admin.E402**: :mod:`django.contrib.auth.context_processors.auth`
    
  781.   must be enabled in :class:`~django.template.backends.django.DjangoTemplates`
    
  782.   (:setting:`TEMPLATES`) if using the default auth backend in order to use the
    
  783.   admin application.
    
  784. * **admin.E403**: A :class:`django.template.backends.django.DjangoTemplates`
    
  785.   instance must be configured in :setting:`TEMPLATES` in order to use the
    
  786.   admin application.
    
  787. * **admin.E404**: ``django.contrib.messages.context_processors.messages``
    
  788.   must be enabled in :class:`~django.template.backends.django.DjangoTemplates`
    
  789.   (:setting:`TEMPLATES`) in order to use the admin application.
    
  790. * **admin.E405**: :mod:`django.contrib.auth` must be in
    
  791.   :setting:`INSTALLED_APPS` in order to use the admin application.
    
  792. * **admin.E406**: :mod:`django.contrib.messages` must be in
    
  793.   :setting:`INSTALLED_APPS` in order to use the admin application.
    
  794. * **admin.E408**:
    
  795.   :class:`django.contrib.auth.middleware.AuthenticationMiddleware` must be in
    
  796.   :setting:`MIDDLEWARE` in order to use the admin application.
    
  797. * **admin.E409**: :class:`django.contrib.messages.middleware.MessageMiddleware`
    
  798.   must be in :setting:`MIDDLEWARE` in order to use the admin application.
    
  799. * **admin.E410**: :class:`django.contrib.sessions.middleware.SessionMiddleware`
    
  800.   must be in :setting:`MIDDLEWARE` in order to use the admin application.
    
  801. * **admin.W411**: ``django.template.context_processors.request`` must be
    
  802.   enabled in :class:`~django.template.backends.django.DjangoTemplates`
    
  803.   (:setting:`TEMPLATES`) in order to use the admin navigation sidebar.
    
  804. 
    
  805. ``auth``
    
  806. --------
    
  807. 
    
  808. * **auth.E001**: ``REQUIRED_FIELDS`` must be a list or tuple.
    
  809. * **auth.E002**: The field named as the ``USERNAME_FIELD`` for a custom user
    
  810.   model must not be included in ``REQUIRED_FIELDS``.
    
  811. * **auth.E003**: ``<field>`` must be unique because it is named as the
    
  812.   ``USERNAME_FIELD``.
    
  813. * **auth.W004**: ``<field>`` is named as the ``USERNAME_FIELD``, but it is not
    
  814.   unique.
    
  815. * **auth.E005**: The permission codenamed ``<codename>`` clashes with a builtin
    
  816.   permission for model ``<model>``.
    
  817. * **auth.E006**: The permission codenamed ``<codename>`` is duplicated for model
    
  818.   ``<model>``.
    
  819. * **auth.E007**: The :attr:`verbose_name
    
  820.   <django.db.models.Options.verbose_name>` of model ``<model>`` must be at most
    
  821.   244 characters for its builtin permission names
    
  822.   to be at most 255 characters.
    
  823. * **auth.E008**: The permission named ``<name>`` of model ``<model>`` is longer
    
  824.   than 255 characters.
    
  825. * **auth.C009**: ``<User model>.is_anonymous`` must be an attribute or property
    
  826.   rather than a method. Ignoring this is a security issue as anonymous users
    
  827.   will be treated as authenticated!
    
  828. * **auth.C010**: ``<User model>.is_authenticated`` must be an attribute or
    
  829.   property rather than a method. Ignoring this is a security issue as anonymous
    
  830.   users will be treated as authenticated!
    
  831. * **auth.E011**: The name of model ``<model>`` must be at most 93 characters
    
  832.   for its builtin permission names to be at most 100 characters.
    
  833. * **auth.E012**: The permission codenamed ``<codename>`` of model ``<model>``
    
  834.   is longer than 100 characters.
    
  835. 
    
  836. ``contenttypes``
    
  837. ----------------
    
  838. 
    
  839. The following checks are performed when a model contains a
    
  840. :class:`~django.contrib.contenttypes.fields.GenericForeignKey` or
    
  841. :class:`~django.contrib.contenttypes.fields.GenericRelation`:
    
  842. 
    
  843. * **contenttypes.E001**: The ``GenericForeignKey`` object ID references the
    
  844.   nonexistent field ``<field>``.
    
  845. * **contenttypes.E002**: The ``GenericForeignKey`` content type references the
    
  846.   nonexistent field ``<field>``.
    
  847. * **contenttypes.E003**: ``<field>`` is not a ``ForeignKey``.
    
  848. * **contenttypes.E004**: ``<field>`` is not a ``ForeignKey`` to
    
  849.   ``contenttypes.ContentType``.
    
  850. * **contenttypes.E005**: Model names must be at most 100 characters.
    
  851. 
    
  852. ``postgres``
    
  853. ------------
    
  854. 
    
  855. The following checks are performed on :mod:`django.contrib.postgres` model
    
  856. fields:
    
  857. 
    
  858. * **postgres.E001**: Base field for array has errors: ...
    
  859. * **postgres.E002**: Base field for array cannot be a related field.
    
  860. * **postgres.E003**: ``<field>`` default should be a callable instead of an
    
  861.   instance so that it's not shared between all field instances. *This check was
    
  862.   changed to* ``fields.E010`` *in Django 3.1*.
    
  863. 
    
  864. ``sites``
    
  865. ---------
    
  866. 
    
  867. The following checks are performed on any model using a
    
  868. :class:`~django.contrib.sites.managers.CurrentSiteManager`:
    
  869. 
    
  870. * **sites.E001**: ``CurrentSiteManager`` could not find a field named
    
  871.   ``<field name>``.
    
  872. * **sites.E002**: ``CurrentSiteManager`` cannot use ``<field>`` as it is not a
    
  873.   foreign key or a many-to-many field.
    
  874. 
    
  875. The following checks verify that :mod:`django.contrib.sites` is correctly
    
  876. configured:
    
  877. 
    
  878. * **sites.E101**: The :setting:`SITE_ID` setting must be an integer.
    
  879. 
    
  880. ``staticfiles``
    
  881. ---------------
    
  882. 
    
  883. The following checks verify that :mod:`django.contrib.staticfiles` is correctly
    
  884. configured:
    
  885. 
    
  886. * **staticfiles.E001**: The :setting:`STATICFILES_DIRS` setting is not a tuple
    
  887.   or list.
    
  888. * **staticfiles.E002**: The :setting:`STATICFILES_DIRS` setting should not
    
  889.   contain the :setting:`STATIC_ROOT` setting.
    
  890. * **staticfiles.E003**: The prefix ``<prefix>`` in the
    
  891.   :setting:`STATICFILES_DIRS` setting must not end with a slash.
    
  892. * **staticfiles.W004**: The directory ``<directory>`` in the
    
  893.   :setting:`STATICFILES_DIRS` does not exist.