checks.txt 43 KB

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