The system check framework is a set of static checks for validating Django projects. It detects common problems and provides hints for how to fix them. The framework is extensible so you can easily add your own checks.
For details on how to add your own checks and integrate them with Django`s system checks, see the System check topic guide.
Django’s system checks are organized using the following tags:
models
: Checks governing model, field and manager definitions.signals
: Checks on signal declarations and handler registrations.admin
: Checks of any admin site declarations.compatibility
: Flagging potential problems with version upgrades.Some checks may be registered with multiple tags.
<swappable>
is not of the form app_label.app_name
.<SETTING>
references <model>
, which has not been
installed, or is abstract.<app_label>.<model>
.id
can only be used as a field name if the field also
sets primary_key=True
.<field name>
from parent model <model>
clashes with the field <field name>
from parent model <model>
.<field name>
from model
<model>
.<field name>
has column name <column name>
that is used by another field.index_together
must be a list or tuple.index_together
elements must be lists or tuples.unique_together
must be a list or tuple.unique_together
elements must be lists or tuples.index_together/unique_together
refers to the
non-existent field <field name>
.index_together/unique_together
refers to a
ManyToManyField
<field name>
, but ManyToManyField
s are not
supported for that option.ordering
must be a tuple or list (even if you want to
order by only one field).ordering
refers to the non-existent field
<field name>
.<model>
contains model fields.<model>.check()
class method is currently overridden."__"
.pk
is a reserved word that cannot be used as a field
name.choices
must be an iterable (e.g., a list or tuple).choices
must be an iterable returning (actual value,
human readable name)
tuples.db_index
must be None
, True
or False
.null=True
.AutoField
s must set primary_key=True.BooleanField
s do not accept null values.CharField
s must define a max_length
attribute.max_length
must be a positive integer.DecimalField
s must define a decimal_places
attribute.decimal_places
must be a non-negative integer.DecimalField
s must define a max_digits
attribute.max_digits
must be a non-negative integer.max_digits
must be greater or equal to decimal_places
.FilePathField
s must have either allow_files
or
allow_folders
set to True.GenericIPAddressField
s cannot accept blank values if
null values are not allowed, as blank values are stored as nulls.unique
is not a valid argument for a FileField
.primary_key
is not a valid argument for a FileField
.ImageField
because Pillow is not installed.<handler>
was connected to the <signal>
signal with
a lazy reference to the <model>
sender, which has not been installed.The following checks are performed to warn the user of any potential problems that might occur as a result of a version upgrade.
BooleanField
does not have a default value.MIDDLEWARE_CLASSES.
django.contrib.sessions.middleware.SessionMiddleware
,
django.contrib.auth.middleware.AuthenticationMiddleware
, and
django.contrib.messages.middleware.MessageMiddleware
were removed from
the defaults. If your project needs these middleware then you should
configure this setting.Admin checks are all performed as part of the admin
tag.
The following checks are performed on any
ModelAdmin
(or subclass) that is registered
with the admin site:
raw_id_fields
must be a list or tuple.raw_id_fields[n]
refers to <field name>
,
which is not an attribute of <model>
.raw_id_fields[n]
must be a ForeignKey
or
ManyToManyField
.fields
must be a list or tuple.fieldsets
and fields
are specified.fields
contains duplicate field(s).fieldsets
must be a list or tuple.fieldsets[n]
must be a list or tuple.fieldsets[n]
must be of length 2.fieldsets[n][1]
must be a dictionary.fieldsets[n][1]
must contain the key
fields
.fieldsets[n][1]
.fields[n]/fieldsets[n][m]
cannot include the
ManyToManyField
<field name>
, because that field manually specifies a
relationship model.exclude
must be a list or tuple.exclude
contains duplicate field(s).form
must inherit from BaseModelForm
.filter_vertical
must be a list or tuple.filter_horizontal
must be a list or tuple.filter_vertical[n]/filter_vertical[n]
refers
to <field name>
, which is not an attribute of <model>
.filter_vertical[n]/filter_vertical[n]
must
be a ManyToManyField
.radio_fields
must be a dictionary.radio_fields
refers to <field name>
,
which is not an attribute of <model>
.radio_fields
refers to <field name>
,
which is not a ForeignKey
, and does not have a choices
definition.radio_fields[<field name>]
must be either
admin.HORIZONTAL
or admin.VERTICAL
.view_on_site
must be either a callable or a
boolean value.prepopulated_fields
must be a dictionary.prepopulated_fields
refers to
<field name>
, which is not an attribute of <model>
.prepopulated_fields
refers to
<field name>
, which must not be a DateTimeField
, ForeignKey
or
ManyToManyField
.prepopulated_fields[<field name>]
must be a
list or tuple.prepopulated_fields
refers to
<field name>
, which is not an attribute of <model>
.ordering
must be a list or tuple.ordering
has the random ordering marker
?
, but contains other fields as well.ordering
refers to <field name>
, which
is not an attribute of <model>
.readonly_fields
must be a list or tuple.readonly_fields[n]
is not a callable, an
attribute of <ModelAdmin class>
, or an attribute of <model>
.The following checks are performed on any
ModelAdmin
that is registered
with the admin site:
save_as
must be a boolean.save_on_top
must be a boolean.inlines
must be a list or tuple.<InlineModelAdmin class>
must inherit from
BaseModelAdmin
.<InlineModelAdmin class>
must have a model
attribute.<InlineModelAdmin class>.model
must be a
Model
.list_display
must be a list or tuple.list_display[n]
refers to <label>
,
which is not a callable, an attribute of <ModelAdmin class>
, or an
attribute or method on <model>
.list_display[n]
must not be a
ManyToManyField
.list_display_links
must be a list, a tuple,
or None
.list_display_links[n]
refers to <label>
,
which is not defined in list_display
.list_filter
must be a list or tuple.list_filter[n]
must inherit from
ListFilter
.list_filter[n]
must not inherit from
FieldListFilter
.list_filter[n][1]
must inherit from
FieldListFilter
.list_filter[n]
refers to <label>
,
which does not refer to a Field.list_select_related
must be a boolean,
tuple or list.list_per_page
must be an integer.list_max_show_all
must be an integer.list_editable
must be a list or tuple.list_editable[n]
refers to <label>
,
which is not an attribute of <model>
.list_editable[n]
refers to <label>
,
which is not contained in list_display
.list_editable[n]
cannot be in both
list_editable
and list_display_links
.list_editable[n]
refers to the first field
in list_display
(<label>
), which cannot be used unless
list_display_links
is set.list_editable[n]
refers to <field name>
,
which is not editable through the admin.search_fields
must be a list or tuple.date_hierarchy
refers to <field name>
,
which is not an attribute of <model>
.date_hierarchy
must be a DateField
or
DateTimeField
.The following checks are performed on any
InlineModelAdmin
that is registered as an
inline on a ModelAdmin
.
<field name>
, because it is the
foreign key to the parent model <app_label>.<model>
.<model>
has no ForeignKey
to <parent model>
./
<model>
has more than one ForeignKey
to <parent model>
.extra
must be an integer.max_num
must be an integer.min_num
must be an integer.formset
must inherit from
BaseModelFormSet
.The following checks are performed on any
GenericInlineModelAdmin
that is
registered as an inline on a ModelAdmin
.
'ct_field'
references <label>
, which is not a field
on <model>
.'ct_fk_field'
references <label>
, which is not a
field on <model>
.<model>
has no GenericForeignKey
.<model>
has no GenericForeignKey
using content type
field <field name>
and object ID field <field name>
.REQUIRED_FIELDS
must be a list or tuple.USERNAME_FIELD
for a custom user
model must not be included in REQUIRED_FIELDS
.<field>
must be unique because it is named as the
USERNAME_FIELD
.<field>
is named as the USERNAME_FIELD
, but it is not
unique.The following checks are performed when a model contains a
GenericForeignKey
or
GenericRelation
:
GenericForeignKey
object ID references the
non-existent field <field>
.GenericForeignKey
content type references the
non-existent field <field>
.<field>
is not a ForeignKey
.<field>
is not a ForeignKey
to
contenttypes.ContentType
.The following checks are performed on any model using a
CurrentSiteManager
:
CurrentSiteManager
could not find a field named
<field name>
.CurrentSiteManager
cannot use <field>
as it is not a
ForeignKey
or ManyToManyField
.Feb 24, 2017