checks.txt 46 KB

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