7
The system check framework is a set of static checks for validating Django
8
projects. It detects common problems and provides hints for how to fix them.
9
The framework is extensible so you can easily add your own checks.
11
For details on how to add your own checks and integrate them with Django`s
12
system checks, see the :doc:`System check topic guide </topics/checks>`.
17
Django's system checks are organized using the following tags:
19
* ``models``: Checks governing model, field and manager definitions.
20
* ``signals``: Checks on signal declarations and handler registrations.
21
* ``admin``: Checks of any admin site declarations.
22
* ``compatibility``: Flagging potential problems with version upgrades.
24
Some checks may be registered with multiple tags.
32
* **models.E001**: ``<swappable>`` is not of the form ``app_label.app_name``.
33
* **models.E002**: ``<SETTING>`` references ``<model>``, which has not been
34
installed, or is abstract.
35
* **models.E003**: The model has two many-to-many relations through the
36
intermediate model ``<app_label>.<model>``.
37
* **models.E004**: ``id`` can only be used as a field name if the field also
38
sets ``primary_key=True``.
39
* **models.E005**: The field ``<field name>`` from parent model ``<model>``
40
clashes with the field ``<field name>`` from parent model ``<model>``.
41
* **models.E006**: The field clashes with the field ``<field name>`` from model
43
* **models.E007**: Field ``<field name>`` has column name ``<column name>``
44
that is used by another field.
45
* **models.E008**: ``index_together`` must be a list or tuple.
46
* **models.E009**: All ``index_together`` elements must be lists or tuples.
47
* **models.E010**: ``unique_together`` must be a list or tuple.
48
* **models.E011**: All ``unique_together`` elements must be lists or tuples.
49
* **models.E012**: ``index_together/unique_together`` refers to the
50
non-existent field ``<field name>``.
51
* **models.E013**: ``index_together/unique_together`` refers to a
52
``ManyToManyField`` ``<field name>``, but ``ManyToManyField``\s are not
53
supported for that option.
54
* **models.E014**: ``ordering`` must be a tuple or list (even if you want to
55
order by only one field).
56
* **models.E015**: ``ordering`` refers to the non-existent field
58
* **models.E017**: Proxy model ``<model>`` contains model fields.
63
* **fields.E001**: Field names must not end with an underscore.
64
* **fields.E002**: Field names must not contain ``"__"``.
65
* **fields.E003**: ``pk`` is a reserved word that cannot be used as a field
67
* **fields.E004**: ``choices`` must be an iterable (e.g., a list or tuple).
68
* **fields.E005**: ``choices`` must be an iterable returning ``(actual value,
69
human readable name)`` tuples.
70
* **fields.E006**: ``db_index`` must be ``None``, ``True`` or ``False``.
71
* **fields.E007**: Primary keys must not have ``null=True``.
72
* **fields.E100**: ``AutoField``\s must set primary_key=True.
73
* **fields.E110**: ``BooleanField``\s do not accept null values.
74
* **fields.E120**: ``CharField``\s must define a ``max_length`` attribute.
75
* **fields.E121**: ``max_length`` must be a positive integer.
76
* **fields.E130**: ``DecimalField``\s must define a ``decimal_places`` attribute.
77
* **fields.E131**: ``decimal_places`` must be a non-negative integer.
78
* **fields.E132**: ``DecimalField``\s must define a ``max_digits`` attribute.
79
* **fields.E133**: ``max_digits`` must be a non-negative integer.
80
* **fields.E134**: ``max_digits`` must be greater or equal to ``decimal_places``.
81
* **fields.E140**: ``FilePathField``\s must have either ``allow_files`` or
82
``allow_folders`` set to True.
83
* **fields.E150**: ``GenericIPAddressField``\s cannot accept blank values if
84
null values are not allowed, as blank values are stored as nulls.
89
* **fields.E200**: ``unique`` is not a valid argument for a ``FileField``.
90
* **fields.E201**: ``primary_key`` is not a valid argument for a ``FileField``.
91
* **fields.E210**: Cannot use ``ImageField`` because Pillow is not installed.
96
* **fields.E300**: Field defines a relation with model ``<model>``, which is
97
either not installed, or is abstract.
98
* **fields.E301**: Field defines a relation with the model ``<model>`` which
100
* **fields.E302**: Accessor for field ``<field name>`` clashes with field
102
* **fields.E303**: Reverse query name for field ``<field name>`` clashes with
103
field ``<field name>``.
104
* **fields.E304**: Field name ``<field name>`` clashes with accessor for
106
* **fields.E305**: Field name ``<field name>`` clashes with reverse query name
107
for ``<field name>``.
108
* **fields.E310**: None of the fields ``<field1>``, ``<field2>``, ... on model
109
``<model>`` have a ``unique=True`` constraint.
110
* **fields.E311**: ``<model>`` must set ``unique=True`` because it is
111
referenced by a ``ForeignKey``.
112
* **fields.E320**: Field specifies ``on_delete=SET_NULL``, but cannot be null.
113
* **fields.E321**: The field specifies ``on_delete=SET_DEFAULT``, but has no
115
* **fields.E330**: ``ManyToManyField``\s cannot be unique.
116
* **fields.E331**: Field specifies a many-to-many relation through model
117
``<model>``, which has not been installed.
118
* **fields.E332**: Many-to-many fields with intermediate tables must not be
120
* **fields.E333**: The model is used as an intermediate model by ``<model>``,
121
but it has more than two foreign keys to ``<model>``, which is ambiguous.
122
You must specify which two foreign keys Django should use via the
123
``through_fields`` keyword argument.
124
* **fields.E334**: The model is used as an intermediate model by ``<model>``,
125
but it has more than one foreign key from ``<model>``, which is ambiguous.
126
You must specify which foreign key Django should use via the
127
``through_fields`` keyword argument.
128
* **fields.E335**: The model is used as an intermediate model by ``<model>``,
129
but it has more than one foreign key to ``<model>``, which is ambiguous.
130
You must specify which foreign key Django should use via the
131
``through_fields`` keyword argument.
132
* **fields.E336**: The model is used as an intermediary model by ``<model>``,
133
but it does not have foreign key to ``<model>`` or ``<model>``.
134
* **fields.E337**: Field specifies ``through_fields`` but does not provide the
135
names of the two link fields that should be used for the relation through
137
* **fields.E338**: The intermediary model ``<through model>`` has no field
139
* **fields.E339**: ``<model>.<field name>`` is not a foreign key to ``<model>``.
144
* **signals.E001**: ``<handler>`` was connected to the ``<signal>`` signal with
145
a lazy reference to the ``<model>`` sender, which has not been installed.
147
Backwards Compatibility
148
~~~~~~~~~~~~~~~~~~~~~~~
150
The following checks are performed to warn the user of any potential problems
151
that might occur as a result of a version upgrade.
153
* **1_6.W001**: Some project unit tests may not execute as expected.
154
* **1_6.W002**: ``BooleanField`` does not have a default value.
159
Admin checks are all performed as part of the ``admin`` tag.
161
The following checks are performed on any
162
:class:`~django.contrib.admin.ModelAdmin` (or subclass) that is registered
165
* **admin.E001**: The value of ``raw_id_fields`` must be a list or tuple.
166
* **admin.E002**: The value of ``raw_id_fields[n]`` refers to ``<field name>``,
167
which is not an attribute of ``<model>``.
168
* **admin.E003**: The value of ``raw_id_fields[n]`` must be a ``ForeignKey`` or
170
* **admin.E004**: The value of ``fields`` must be a list or tuple.
171
* **admin.E005**: Both ``fieldsets`` and ``fields`` are specified.
172
* **admin.E006**: The value of ``fields`` contains duplicate field(s).
173
* **admin.E007**: The value of ``fieldsets`` must be a list or tuple.
174
* **admin.E008**: The value of ``fieldsets[n]`` must be a list or tuple.
175
* **admin.E009**: The value of ``fieldsets[n]`` must be of length 2.
176
* **admin.E010**: The value of ``fieldsets[n][1]`` must be a dictionary.
177
* **admin.E011**: The value of ``fieldsets[n][1]`` must contain the key
179
* **admin.E012**: There are duplicate field(s) in ``fieldsets[n][1]``.
180
* **admin.E013**: ``fields[n]/fieldsets[n][m]`` cannot include the
181
``ManyToManyField`` ``<field name>``, because that field manually specifies a
183
* **admin.E014**: The value of ``exclude`` must be a list or tuple.
184
* **admin.E015**: The value of ``exclude`` contains duplicate field(s).
185
* **admin.E016**: The value of ``form`` must inherit from ``BaseModelForm``.
186
* **admin.E017**: The value of ``filter_vertical`` must be a list or tuple.
187
* **admin.E018**: The value of ``filter_horizontal`` must be a list or tuple.
188
* **admin.E019**: The value of ``filter_vertical[n]/filter_vertical[n]`` refers
189
to ``<field name>``, which is not an attribute of ``<model>``.
190
* **admin.E020**: The value of ``filter_vertical[n]/filter_vertical[n]`` must
191
be a ``ManyToManyField``.
192
* **admin.E021**: The value of ``radio_fields`` must be a dictionary.
193
* **admin.E022**: The value of ``radio_fields`` refers to ``<field name>``,
194
which is not an attribute of ``<model>``.
195
* **admin.E023**: The value of ``radio_fields`` refers to ``<field name>``,
196
which is not a ``ForeignKey``, and does not have a ``choices`` definition.
197
* **admin.E024**: The value of ``radio_fields[<field name>]`` must be either
198
``admin.HORIZONTAL`` nor ``admin.VERTICAL``.
199
* **admin.E025**: The value of ``view_on_site`` must be either a callable or a
201
* **admin.E026**: The value of ``prepopulated_fields`` must be a dictionary.
202
* **admin.E027**: The value of ``prepopulated_fields`` refers to
203
``<field name>``, which is not an attribute of ``<model>``.
204
* **admin.E028**: The value of ``prepopulated_fields`` refers to
205
``<field name>``, which must not be a ``DateTimeField``, ``ForeignKey`` or
207
* **admin.E029**: The value of ``prepopulated_fields[<field name>]`` must be a
209
* **admin.E030**: The value of ``prepopulated_fields`` refers to
210
``<field name>``, which is not an attribute of ``<model>``.
211
* **admin.E031**: The value of ``ordering`` must be a list or tuple.
212
* **admin.E032**: The value of ``ordering`` has the random ordering marker
213
``?``, but contains other fields as well.
214
* **admin.E033**: The value of ``ordering`` refers to ``<field name>``, which
215
is not an attribute of ``<model>``.
216
* **admin.E034**: The value of ``readonly_fields`` must be a list or tuple.
217
* **admin.E035**: The value of ``readonly_fields[n]`` is not a callable, an
218
attribute of ``<ModelAdmin class>``, or an attribute of ``<model>``.
223
The following checks are performed on any
224
:class:`~django.contrib.admin.ModelAdmin` that is registered
227
* **admin.E101**: The value of ``save_as`` must be a boolean.
228
* **admin.E102**: The value of ``save_on_top`` must be a boolean.
229
* **admin.E103**: The value of ``inlines`` must be a list or tuple.
230
* **admin.E104**: ``<InlineModelAdmin class>`` must inherit from
232
* **admin.E105**: ``<InlineModelAdmin class>`` must have a ``model`` attribute.
233
* **admin.E106**: The value of ``<InlineModelAdmin class>.model`` must be a
235
* **admin.E107**: The value of ``list_display`` must be a list or tuple.
236
* **admin.E108**: The value of ``list_display[n]`` refers to ``<label>``,
237
which is not a callable, an attribute of ``<ModelAdmin class>``, or an
238
attribute or method on ``<model>``.
239
* **admin.E109**: The value of ``list_display[n]`` must not be a
241
* **admin.E110**: The value of ``list_display_links`` must be a list, a tuple,
243
* **admin.E111**: The value of ``list_display_links[n]`` refers to ``<label>``,
244
which is not defined in ``list_display``.
245
* **admin.E112**: The value of ``list_filter`` must be a list or tuple.
246
* **admin.E113**: The value of ``list_filter[n]`` must inherit from
248
* **admin.E114**: The value of ``list_filter[n]`` must not inherit from
250
* **admin.E115**: The value of ``list_filter[n][1]`` must inherit from
252
* **admin.E116**: The value of ``list_filter[n]`` refers to ``<label>``,
253
which does not refer to a Field.
254
* **admin.E117**: The value of ``list_select_related`` must be a boolean,
256
* **admin.E118**: The value of ``list_per_page`` must be an integer.
257
* **admin.E119**: The value of ``list_max_show_all`` must be an integer.
258
* **admin.E120**: The value of ``list_editable`` must be a list or tuple.
259
* **admin.E121**: The value of ``list_editable[n]`` refers to ``<label>``,
260
which is not an attribute of ``<model>``.
261
* **admin.E122**: The value of ``list_editable[n]`` refers to ``<label>``,
262
which is not contained in ``list_display``.
263
* **admin.E123**: The value of ``list_editable[n]`` cannot be in both
264
``list_editable`` and ``list_display_links``.
265
* **admin.E124**: The value of ``list_editable[n]`` refers to the first field
266
in ``list_display`` (``<label>``), which cannot be used unless
267
``list_display_links`` is set.
268
* **admin.E125**: The value of ``list_editable[n]`` refers to ``<field name>``,
269
which is not editable through the admin.
270
* **admin.E126**: The value of ``search_fields`` must be a list or tuple.
271
* **admin.E127**: The value of ``date_hierarchy`` refers to ``<field name>``,
272
which is not an attribute of ``<model>``.
273
* **admin.E128**: The value of ``date_hierarchy`` must be a ``DateField`` or
279
The following checks are performed on any
280
:class:`~django.contrib.admin.InlineModelAdmin` that is registered as an
281
inline on a :class:`~django.contrib.admin.ModelAdmin`.
283
* **admin.E201**: Cannot exclude the field ``<field name>``, because it is the
284
foreign key to the parent model ``<app_label>.<model>``.
285
* **admin.E202**: ``<model>`` has no ``ForeignKey`` to ``<parent model>``./
286
``<model>`` has more than one ``ForeignKey`` to ``<parent model>``.
287
* **admin.E203**: The value of ``extra`` must be an integer.
288
* **admin.E204**: The value of ``max_num`` must be an integer.
289
* **admin.E205**: The value of ``min_num`` must be an integer.
290
* **admin.E206**: The value of ``formset`` must inherit from
291
``BaseModelFormSet``.
293
GenericInlineModelAdmin
294
~~~~~~~~~~~~~~~~~~~~~~~
296
The following checks are performed on any
297
:class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin` that is
298
registered as an inline on a :class:`~django.contrib.admin.ModelAdmin`.
300
* **admin.E301**: ``'ct_field'`` references ``<label>``, which is not a field
302
* **admin.E302**: ``'ct_fk_field'`` references ``<label>``, which is not a
303
field on ``<model>``.
304
* **admin.E303**: ``<model>`` has no ``GenericForeignKey``.
305
* **admin.E304**: ``<model>`` has no ``GenericForeignKey`` using content type
306
field ``<field name>`` and object ID field ``<field name>``.
312
* **auth.E001**: ``REQUIRED_FIELDS`` must be a list or tuple.
313
* **auth.E002**: The field named as the ``USERNAME_FIELD`` for a custom user
314
model must not be included in ``REQUIRED_FIELDS``.
315
* **auth.E003**: ``<field>`` must be unique because it is named as the
317
* **auth.W004**: ``<field>`` is named as the ``USERNAME_FIELD``, but it is not
324
The following checks are performed when a model contains a
325
:class:`~django.contrib.contenttypes.fields.GenericForeignKey` or
326
:class:`~django.contrib.contenttypes.fields.GenericRelation`:
328
* **contenttypes.E001**: The ``GenericForeignKey`` object ID references the
329
non-existent field ``<field>``
330
* **contenttypes.E002**: The ``GenericForeignKey`` content type references the
331
non-existent field ``<field>``
332
* **contenttypes.E003**: ``<field>`` is not a ``ForeignKey``.
333
* **contenttypes.E004**: ``<field>`` is not a ``ForeignKey`` to
334
``contenttypes.ContentType``
339
The following checks are performed on any model using a
340
:class:`~django.contrib.sites.managers.CurrentSiteManager`:
342
* **sites.E001**: ``CurrentSiteManager`` could not find a field named
344
* **sites.E002**: ``CurrentSiteManager`` cannot use ``<field>`` as it is not a
345
``ForeignKey`` or ``ManyToManyField``.
353
If you're using MySQL, the following checks will be performed:
355
* **mysql.E001**: MySQL does not allow unique ``CharField``\s to have a
356
``max_length`` > 255.