checks.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. ======================
  2. System check framework
  3. ======================
  4. .. versionadded:: 1.7
  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. Builtin tags
  11. ------------
  12. Django's system checks are organized using the following tags:
  13. * ``models``: Checks governing model, field and manager definitions.
  14. * ``signals``: Checks on signal declarations and handler registrations.
  15. * ``admin``: Checks of any admin site declarations.
  16. * ``compatibility``: Flagging potential problems with version upgrades.
  17. * ``security``: Checks security related configuration.
  18. Some checks may be registered with multiple tags.
  19. Core system checks
  20. ------------------
  21. Models
  22. ~~~~~~
  23. * **models.E001**: ``<swappable>`` is not of the form ``app_label.app_name``.
  24. * **models.E002**: ``<SETTING>`` references ``<model>``, which has not been
  25. installed, or is abstract.
  26. * **models.E003**: The model has two many-to-many relations through the
  27. intermediate model ``<app_label>.<model>``.
  28. * **models.E004**: ``id`` can only be used as a field name if the field also
  29. sets ``primary_key=True``.
  30. * **models.E005**: The field ``<field name>`` from parent model ``<model>``
  31. clashes with the field ``<field name>`` from parent model ``<model>``.
  32. * **models.E006**: The field clashes with the field ``<field name>`` from model
  33. ``<model>``.
  34. * **models.E007**: Field ``<field name>`` has column name ``<column name>``
  35. that is used by another field.
  36. * **models.E008**: ``index_together`` must be a list or tuple.
  37. * **models.E009**: All ``index_together`` elements must be lists or tuples.
  38. * **models.E010**: ``unique_together`` must be a list or tuple.
  39. * **models.E011**: All ``unique_together`` elements must be lists or tuples.
  40. * **models.E012**: ``index_together/unique_together`` refers to the
  41. non-existent field ``<field name>``.
  42. * **models.E013**: ``index_together/unique_together`` refers to a
  43. ``ManyToManyField`` ``<field name>``, but ``ManyToManyField``\s are not
  44. supported for that option.
  45. * **models.E014**: ``ordering`` must be a tuple or list (even if you want to
  46. order by only one field).
  47. * **models.E015**: ``ordering`` refers to the non-existent field
  48. ``<field name>``.
  49. * **models.E016**: ``index_together/unique_together`` refers to field
  50. ``<field_name>`` which is not local to model ``<model>``.
  51. * **models.E017**: Proxy model ``<model>`` contains model fields.
  52. * **models.E018**: Autogenerated column name too long for field ``<field>``.
  53. Maximum length is ``<maximum length>`` for database ``<alias>``.
  54. * **models.E019**: Autogenerated column name too long for M2M field
  55. ``<M2M field>``. Maximum length is ``<maximum length>`` for database
  56. ``<alias>``.
  57. Fields
  58. ~~~~~~
  59. * **fields.E001**: Field names must not end with an underscore.
  60. * **fields.E002**: Field names must not contain ``"__"``.
  61. * **fields.E003**: ``pk`` is a reserved word that cannot be used as a field
  62. name.
  63. * **fields.E004**: ``choices`` must be an iterable (e.g., a list or tuple).
  64. * **fields.E005**: ``choices`` must be an iterable returning ``(actual value,
  65. human readable name)`` tuples.
  66. * **fields.E006**: ``db_index`` must be ``None``, ``True`` or ``False``.
  67. * **fields.E007**: Primary keys must not have ``null=True``.
  68. * **fields.E100**: ``AutoField``\s must set primary_key=True.
  69. * **fields.E110**: ``BooleanField``\s do not accept null values.
  70. * **fields.E120**: ``CharField``\s must define a ``max_length`` attribute.
  71. * **fields.E121**: ``max_length`` must be a positive integer.
  72. * **fields.E130**: ``DecimalField``\s must define a ``decimal_places`` attribute.
  73. * **fields.E131**: ``decimal_places`` must be a non-negative integer.
  74. * **fields.E132**: ``DecimalField``\s must define a ``max_digits`` attribute.
  75. * **fields.E133**: ``max_digits`` must be a non-negative integer.
  76. * **fields.E134**: ``max_digits`` must be greater or equal to ``decimal_places``.
  77. * **fields.E140**: ``FilePathField``\s must have either ``allow_files`` or
  78. ``allow_folders`` set to True.
  79. * **fields.E150**: ``GenericIPAddressField``\s cannot accept blank values if
  80. null values are not allowed, as blank values are stored as nulls.
  81. * **fields.E160**: The options ``auto_now``, ``auto_now_add``, and ``default``
  82. are mutually exclusive. Only one of these options may be present.
  83. * **fields.W161**: Fixed default value provided.
  84. File Fields
  85. ~~~~~~~~~~~
  86. * **fields.E200**: ``unique`` is not a valid argument for a ``FileField``.
  87. * **fields.E201**: ``primary_key`` is not a valid argument for a ``FileField``.
  88. * **fields.E210**: Cannot use ``ImageField`` because Pillow is not installed.
  89. Related Fields
  90. ~~~~~~~~~~~~~~
  91. * **fields.E300**: Field defines a relation with model ``<model>``, which is
  92. either not installed, or is abstract.
  93. * **fields.E301**: Field defines a relation with the model ``<model>`` which
  94. has been swapped out.
  95. * **fields.E302**: Accessor for field ``<field name>`` clashes with field
  96. ``<field name>``.
  97. * **fields.E303**: Reverse query name for field ``<field name>`` clashes with
  98. field ``<field name>``.
  99. * **fields.E304**: Field name ``<field name>`` clashes with accessor for
  100. ``<field name>``.
  101. * **fields.E305**: Field name ``<field name>`` clashes with reverse query name
  102. for ``<field name>``.
  103. * **fields.E310**: None of the fields ``<field1>``, ``<field2>``, ... on model
  104. ``<model>`` have a ``unique=True`` constraint.
  105. * **fields.E311**: ``<model>`` must set ``unique=True`` because it is
  106. referenced by a ``ForeignKey``.
  107. * **fields.E320**: Field specifies ``on_delete=SET_NULL``, but cannot be null.
  108. * **fields.E321**: The field specifies ``on_delete=SET_DEFAULT``, but has no
  109. default value.
  110. * **fields.E330**: ``ManyToManyField``\s cannot be unique.
  111. * **fields.E331**: Field specifies a many-to-many relation through model
  112. ``<model>``, which has not been installed.
  113. * **fields.E332**: Many-to-many fields with intermediate tables must not be
  114. symmetrical.
  115. * **fields.E333**: The model is used as an intermediate model by ``<model>``,
  116. but it has more than two foreign keys to ``<model>``, which is ambiguous.
  117. You must specify which two foreign keys Django should use via the
  118. ``through_fields`` keyword argument.
  119. * **fields.E334**: The model is used as an intermediate model by ``<model>``,
  120. but it has more than one foreign key from ``<model>``, which is ambiguous.
  121. You must specify which foreign key Django should use via the
  122. ``through_fields`` keyword argument.
  123. * **fields.E335**: The model is used as an intermediate model by ``<model>``,
  124. but it has more than one foreign key to ``<model>``, which is ambiguous.
  125. You must specify which foreign key Django should use via the
  126. ``through_fields`` keyword argument.
  127. * **fields.E336**: The model is used as an intermediary model by ``<model>``,
  128. but it does not have foreign key to ``<model>`` or ``<model>``.
  129. * **fields.E337**: Field specifies ``through_fields`` but does not provide the
  130. names of the two link fields that should be used for the relation through
  131. ``<model>``.
  132. * **fields.E338**: The intermediary model ``<through model>`` has no field
  133. ``<field name>``.
  134. * **fields.E339**: ``<model>.<field name>`` is not a foreign key to ``<model>``.
  135. * **fields.W340**: ``null`` has no effect on ``ManyToManyField``.
  136. * **fields.W341**: ``ManyToManyField`` does not support ``validators``.
  137. Signals
  138. ~~~~~~~
  139. * **signals.E001**: ``<handler>`` was connected to the ``<signal>`` signal with
  140. a lazy reference to the ``<model>`` sender, which has not been installed.
  141. Backwards Compatibility
  142. ~~~~~~~~~~~~~~~~~~~~~~~
  143. The following checks are performed to warn the user of any potential problems
  144. that might occur as a result of a version upgrade.
  145. * **1_6.W001**: Some project unit tests may not execute as expected.
  146. * **1_6.W002**: ``BooleanField`` does not have a default value.
  147. Admin
  148. -----
  149. Admin checks are all performed as part of the ``admin`` tag.
  150. The following checks are performed on any
  151. :class:`~django.contrib.admin.ModelAdmin` (or subclass) that is registered
  152. with the admin site:
  153. * **admin.E001**: The value of ``raw_id_fields`` must be a list or tuple.
  154. * **admin.E002**: The value of ``raw_id_fields[n]`` refers to ``<field name>``,
  155. which is not an attribute of ``<model>``.
  156. * **admin.E003**: The value of ``raw_id_fields[n]`` must be a ``ForeignKey`` or
  157. ``ManyToManyField``.
  158. * **admin.E004**: The value of ``fields`` must be a list or tuple.
  159. * **admin.E005**: Both ``fieldsets`` and ``fields`` are specified.
  160. * **admin.E006**: The value of ``fields`` contains duplicate field(s).
  161. * **admin.E007**: The value of ``fieldsets`` must be a list or tuple.
  162. * **admin.E008**: The value of ``fieldsets[n]`` must be a list or tuple.
  163. * **admin.E009**: The value of ``fieldsets[n]`` must be of length 2.
  164. * **admin.E010**: The value of ``fieldsets[n][1]`` must be a dictionary.
  165. * **admin.E011**: The value of ``fieldsets[n][1]`` must contain the key
  166. ``fields``.
  167. * **admin.E012**: There are duplicate field(s) in ``fieldsets[n][1]``.
  168. * **admin.E013**: ``fields[n]/fieldsets[n][m]`` cannot include the
  169. ``ManyToManyField`` ``<field name>``, because that field manually specifies a
  170. relationship model.
  171. * **admin.E014**: The value of ``exclude`` must be a list or tuple.
  172. * **admin.E015**: The value of ``exclude`` contains duplicate field(s).
  173. * **admin.E016**: The value of ``form`` must inherit from ``BaseModelForm``.
  174. * **admin.E017**: The value of ``filter_vertical`` must be a list or tuple.
  175. * **admin.E018**: The value of ``filter_horizontal`` must be a list or tuple.
  176. * **admin.E019**: The value of ``filter_vertical[n]/filter_vertical[n]`` refers
  177. to ``<field name>``, which is not an attribute of ``<model>``.
  178. * **admin.E020**: The value of ``filter_vertical[n]/filter_vertical[n]`` must
  179. be a ``ManyToManyField``.
  180. * **admin.E021**: The value of ``radio_fields`` must be a dictionary.
  181. * **admin.E022**: The value of ``radio_fields`` refers to ``<field name>``,
  182. which is not an attribute of ``<model>``.
  183. * **admin.E023**: The value of ``radio_fields`` refers to ``<field name>``,
  184. which is not a ``ForeignKey``, and does not have a ``choices`` definition.
  185. * **admin.E024**: The value of ``radio_fields[<field name>]`` must be either
  186. ``admin.HORIZONTAL`` or ``admin.VERTICAL``.
  187. * **admin.E025**: The value of ``view_on_site`` must be either a callable or a
  188. boolean value.
  189. * **admin.E026**: The value of ``prepopulated_fields`` must be a dictionary.
  190. * **admin.E027**: The value of ``prepopulated_fields`` refers to
  191. ``<field name>``, which is not an attribute of ``<model>``.
  192. * **admin.E028**: The value of ``prepopulated_fields`` refers to
  193. ``<field name>``, which must not be a ``DateTimeField``, ``ForeignKey`` or
  194. ``ManyToManyField``.
  195. * **admin.E029**: The value of ``prepopulated_fields[<field name>]`` must be a
  196. list or tuple.
  197. * **admin.E030**: The value of ``prepopulated_fields`` refers to
  198. ``<field name>``, which is not an attribute of ``<model>``.
  199. * **admin.E031**: The value of ``ordering`` must be a list or tuple.
  200. * **admin.E032**: The value of ``ordering`` has the random ordering marker
  201. ``?``, but contains other fields as well.
  202. * **admin.E033**: The value of ``ordering`` refers to ``<field name>``, which
  203. is not an attribute of ``<model>``.
  204. * **admin.E034**: The value of ``readonly_fields`` must be a list or tuple.
  205. * **admin.E035**: The value of ``readonly_fields[n]`` is not a callable, an
  206. attribute of ``<ModelAdmin class>``, or an attribute of ``<model>``.
  207. ModelAdmin
  208. ~~~~~~~~~~
  209. The following checks are performed on any
  210. :class:`~django.contrib.admin.ModelAdmin` that is registered
  211. with the admin site:
  212. * **admin.E101**: The value of ``save_as`` must be a boolean.
  213. * **admin.E102**: The value of ``save_on_top`` must be a boolean.
  214. * **admin.E103**: The value of ``inlines`` must be a list or tuple.
  215. * **admin.E104**: ``<InlineModelAdmin class>`` must inherit from
  216. ``BaseModelAdmin``.
  217. * **admin.E105**: ``<InlineModelAdmin class>`` must have a ``model`` attribute.
  218. * **admin.E106**: The value of ``<InlineModelAdmin class>.model`` must be a
  219. ``Model``.
  220. * **admin.E107**: The value of ``list_display`` must be a list or tuple.
  221. * **admin.E108**: The value of ``list_display[n]`` refers to ``<label>``,
  222. which is not a callable, an attribute of ``<ModelAdmin class>``, or an
  223. attribute or method on ``<model>``.
  224. * **admin.E109**: The value of ``list_display[n]`` must not be a
  225. ``ManyToManyField``.
  226. * **admin.E110**: The value of ``list_display_links`` must be a list, a tuple,
  227. or ``None``.
  228. * **admin.E111**: The value of ``list_display_links[n]`` refers to ``<label>``,
  229. which is not defined in ``list_display``.
  230. * **admin.E112**: The value of ``list_filter`` must be a list or tuple.
  231. * **admin.E113**: The value of ``list_filter[n]`` must inherit from
  232. ``ListFilter``.
  233. * **admin.E114**: The value of ``list_filter[n]`` must not inherit from
  234. ``FieldListFilter``.
  235. * **admin.E115**: The value of ``list_filter[n][1]`` must inherit from
  236. ``FieldListFilter``.
  237. * **admin.E116**: The value of ``list_filter[n]`` refers to ``<label>``,
  238. which does not refer to a Field.
  239. * **admin.E117**: The value of ``list_select_related`` must be a boolean,
  240. tuple or list.
  241. * **admin.E118**: The value of ``list_per_page`` must be an integer.
  242. * **admin.E119**: The value of ``list_max_show_all`` must be an integer.
  243. * **admin.E120**: The value of ``list_editable`` must be a list or tuple.
  244. * **admin.E121**: The value of ``list_editable[n]`` refers to ``<label>``,
  245. which is not an attribute of ``<model>``.
  246. * **admin.E122**: The value of ``list_editable[n]`` refers to ``<label>``,
  247. which is not contained in ``list_display``.
  248. * **admin.E123**: The value of ``list_editable[n]`` cannot be in both
  249. ``list_editable`` and ``list_display_links``.
  250. * **admin.E124**: The value of ``list_editable[n]`` refers to the first field
  251. in ``list_display`` (``<label>``), which cannot be used unless
  252. ``list_display_links`` is set.
  253. * **admin.E125**: The value of ``list_editable[n]`` refers to ``<field name>``,
  254. which is not editable through the admin.
  255. * **admin.E126**: The value of ``search_fields`` must be a list or tuple.
  256. * **admin.E127**: The value of ``date_hierarchy`` refers to ``<field name>``,
  257. which is not an attribute of ``<model>``.
  258. * **admin.E128**: The value of ``date_hierarchy`` must be a ``DateField`` or
  259. ``DateTimeField``.
  260. InlineModelAdmin
  261. ~~~~~~~~~~~~~~~~
  262. The following checks are performed on any
  263. :class:`~django.contrib.admin.InlineModelAdmin` that is registered as an
  264. inline on a :class:`~django.contrib.admin.ModelAdmin`.
  265. * **admin.E201**: Cannot exclude the field ``<field name>``, because it is the
  266. foreign key to the parent model ``<app_label>.<model>``.
  267. * **admin.E202**: ``<model>`` has no ``ForeignKey`` to ``<parent model>``./
  268. ``<model>`` has more than one ``ForeignKey`` to ``<parent model>``.
  269. * **admin.E203**: The value of ``extra`` must be an integer.
  270. * **admin.E204**: The value of ``max_num`` must be an integer.
  271. * **admin.E205**: The value of ``min_num`` must be an integer.
  272. * **admin.E206**: The value of ``formset`` must inherit from
  273. ``BaseModelFormSet``.
  274. GenericInlineModelAdmin
  275. ~~~~~~~~~~~~~~~~~~~~~~~
  276. The following checks are performed on any
  277. :class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin` that is
  278. registered as an inline on a :class:`~django.contrib.admin.ModelAdmin`.
  279. * **admin.E301**: ``'ct_field'`` references ``<label>``, which is not a field
  280. on ``<model>``.
  281. * **admin.E302**: ``'ct_fk_field'`` references ``<label>``, which is not a
  282. field on ``<model>``.
  283. * **admin.E303**: ``<model>`` has no ``GenericForeignKey``.
  284. * **admin.E304**: ``<model>`` has no ``GenericForeignKey`` using content type
  285. field ``<field name>`` and object ID field ``<field name>``.
  286. Auth
  287. ----
  288. * **auth.E001**: ``REQUIRED_FIELDS`` must be a list or tuple.
  289. * **auth.E002**: The field named as the ``USERNAME_FIELD`` for a custom user
  290. model must not be included in ``REQUIRED_FIELDS``.
  291. * **auth.E003**: ``<field>`` must be unique because it is named as the
  292. ``USERNAME_FIELD``.
  293. * **auth.W004**: ``<field>`` is named as the ``USERNAME_FIELD``, but it is not
  294. unique.
  295. Content Types
  296. -------------
  297. The following checks are performed when a model contains a
  298. :class:`~django.contrib.contenttypes.fields.GenericForeignKey` or
  299. :class:`~django.contrib.contenttypes.fields.GenericRelation`:
  300. * **contenttypes.E001**: The ``GenericForeignKey`` object ID references the
  301. non-existent field ``<field>``.
  302. * **contenttypes.E002**: The ``GenericForeignKey`` content type references the
  303. non-existent field ``<field>``.
  304. * **contenttypes.E003**: ``<field>`` is not a ``ForeignKey``.
  305. * **contenttypes.E004**: ``<field>`` is not a ``ForeignKey`` to
  306. ``contenttypes.ContentType``.
  307. Security
  308. --------
  309. The security checks do not make your site secure. They do not audit code, do
  310. intrusion detection, or do anything particularly complex. Rather, they help
  311. perform an automated, low-hanging-fruit checklist. They help you remember the
  312. simple things that improve your site's security.
  313. Some of these checks may not be appropriate for your particular deployment
  314. configuration. For instance, if you do your HTTP to HTTPS redirection in a load
  315. balancer, it'd be irritating to be constantly warned about not having enabled
  316. :setting:`SECURE_SSL_REDIRECT`. Use :setting:`SILENCED_SYSTEM_CHECKS` to
  317. silence unneeded checks.
  318. The following checks will be run if you use the :djadminopt:`--deploy` option
  319. of the :djadmin:`check` command:
  320. * **security.W001**: You do not have
  321. :class:`django.middleware.security.SecurityMiddleware` in your
  322. :setting:`MIDDLEWARE_CLASSES` so the :setting:`SECURE_HSTS_SECONDS`,
  323. :setting:`SECURE_CONTENT_TYPE_NOSNIFF`, :setting:`SECURE_BROWSER_XSS_FILTER`,
  324. and :setting:`SECURE_SSL_REDIRECT` settings will have no effect.
  325. * **security.W002**: You do not have
  326. :class:`django.middleware.clickjacking.XFrameOptionsMiddleware` in your
  327. :setting:`MIDDLEWARE_CLASSES`, so your pages will not be served with an
  328. ``'x-frame-options'`` header. Unless there is a good reason for your
  329. site to be served in a frame, you should consider enabling this
  330. header to help prevent clickjacking attacks.
  331. * **security.W003**: You don't appear to be using Django's built-in cross-site
  332. request forgery protection via the middleware
  333. (:class:`django.middleware.csrf.CsrfViewMiddleware` is not in your
  334. :setting:`MIDDLEWARE_CLASSES`). Enabling the middleware is the safest
  335. approach to ensure you don't leave any holes.
  336. * **security.W004**: You have not set a value for the
  337. :setting:`SECURE_HSTS_SECONDS` setting. If your entire site is served only
  338. over SSL, you may want to consider setting a value and enabling :ref:`HTTP
  339. Strict Transport Security <http-strict-transport-security>`. Be sure to read
  340. the documentation first; enabling HSTS carelessly can cause serious,
  341. irreversible problems.
  342. * **security.W005**: You have not set the
  343. :setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS` setting to ``True``. Without this,
  344. your site is potentially vulnerable to attack via an insecure connection to a
  345. subdomain. Only set this to ``True`` if you are certain that all subdomains of
  346. your domain should be served exclusively via SSL.
  347. * **security.W006**: Your :setting:`SECURE_CONTENT_TYPE_NOSNIFF` setting is not
  348. set to ``True``, so your pages will not be served with an
  349. ``'x-content-type-options: nosniff'`` header. You should consider enabling
  350. this header to prevent the browser from identifying content types incorrectly.
  351. * **security.W007**: Your :setting:`SECURE_BROWSER_XSS_FILTER` setting is not
  352. set to ``True``, so your pages will not be served with an
  353. ``'x-xss-protection: 1; mode=block'`` header. You should consider enabling
  354. this header to activate the browser's XSS filtering and help prevent XSS
  355. attacks.
  356. * **security.W008**: Your :setting:`SECURE_SSL_REDIRECT` setting is not set to
  357. ``True``. Unless your site should be available over both SSL and non-SSL
  358. connections, you may want to either set this setting to ``True`` or configure
  359. a load balancer or reverse-proxy server to redirect all connections to HTTPS.
  360. * **security.W009**: Your :setting:`SECRET_KEY` has less than 50 characters or
  361. less than 5 unique characters. Please generate a long and random
  362. ``SECRET_KEY``, otherwise many of Django's security-critical features will be
  363. vulnerable to attack.
  364. * **security.W010**: You have :mod:`django.contrib.sessions` in your
  365. :setting:`INSTALLED_APPS` but you have not set
  366. :setting:`SESSION_COOKIE_SECURE` to ``True``. Using a secure-only session
  367. cookie makes it more difficult for network traffic sniffers to hijack user
  368. sessions.
  369. * **security.W011**: You have
  370. :class:`django.contrib.sessions.middleware.SessionMiddleware` in your
  371. :setting:`MIDDLEWARE_CLASSES`, but you have not set
  372. :setting:`SESSION_COOKIE_SECURE` to ``True``. Using a secure-only session
  373. cookie makes it more difficult for network traffic sniffers to hijack user
  374. sessions.
  375. * **security.W012**: :setting:`SESSION_COOKIE_SECURE` is not set to ``True``.
  376. Using a secure-only session cookie makes it more difficult for network traffic
  377. sniffers to hijack user sessions.
  378. * **security.W013**: You have :mod:`django.contrib.sessions` in your
  379. :setting:`INSTALLED_APPS`, but you have not set
  380. :setting:`SESSION_COOKIE_HTTPONLY` to ``True``. Using an ``HttpOnly`` session
  381. cookie makes it more difficult for cross-site scripting attacks to hijack user
  382. sessions.
  383. * **security.W014**: You have
  384. :class:`django.contrib.sessions.middleware.SessionMiddleware` in your
  385. :setting:`MIDDLEWARE_CLASSES`, but you have not set
  386. :setting:`SESSION_COOKIE_HTTPONLY` to ``True``. Using an ``HttpOnly`` session
  387. cookie makes it more difficult for cross-site scripting attacks to hijack user
  388. sessions.
  389. * **security.W015**: :setting:`SESSION_COOKIE_HTTPONLY` is not set to ``True``.
  390. Using an ``HttpOnly`` session cookie makes it more difficult for cross-site
  391. scripting attacks to hijack user sessions.
  392. * **security.W016**: :setting:`CSRF_COOKIE_SECURE` is not set to ``True``.
  393. Using a secure-only CSRF cookie makes it more difficult for network traffic
  394. sniffers to steal the CSRF token.
  395. * **security.W017**: :setting:`CSRF_COOKIE_HTTPONLY` is not set to ``True``.
  396. Using an ``HttpOnly`` CSRF cookie makes it more difficult for cross-site
  397. scripting attacks to steal the CSRF token.
  398. * **security.W018**: You should not have :setting:`DEBUG` set to ``True`` in
  399. deployment.
  400. * **security.W019**: You have
  401. :class:`django.middleware.clickjacking.XFrameOptionsMiddleware` in your
  402. :setting:`MIDDLEWARE_CLASSES`, but :setting:`X_FRAME_OPTIONS` is not set to
  403. ``'DENY'``. The default is ``'SAMEORIGIN'``, but unless there is a good reason
  404. for your site to serve other parts of itself in a frame, you should change
  405. it to ``'DENY'``.
  406. Sites
  407. -----
  408. The following checks are performed on any model using a
  409. :class:`~django.contrib.sites.managers.CurrentSiteManager`:
  410. * **sites.E001**: ``CurrentSiteManager`` could not find a field named
  411. ``<field name>``.
  412. * **sites.E002**: ``CurrentSiteManager`` cannot use ``<field>`` as it is not a
  413. ``ForeignKey`` or ``ManyToManyField``.
  414. Database
  415. --------
  416. MySQL
  417. ~~~~~
  418. If you're using MySQL, the following checks will be performed:
  419. * **mysql.E001**: MySQL does not allow unique ``CharField``\s to have a
  420. ``max_length`` > 255.