O framework de verificação do sistema é um conjunto de verificações estáticas para validação de projetos Django. Ele detecta problemas comuns e fornece dicas de como arrumá-los. O framework é extensível e você pode facilmente adicionar suas próprias validações.
Para detalhes de como adicionar suas próprias verificações e integrar isso com os sistema de verificação do Django, veja o Tópico sistema de verificação do giua..
CheckMessage
¶Os alertas e erros emitidos pelo sistema de verificação devem ser uma instância de CheckMessage
. Uma instância encapsula um único erro ou aviso. Ele também fornece contexto e dicas aplicáveia a mensagem, e um identificador único que é usado para propósitos de filtragem.
Os argumentos do Construtor são:
level
A gravidade da mensagem. Use um dos valores pré-definidos: DEBUG
, INFO
, WARNING
, ERROR
, CRITICAL
. Se o nível é maior ou igual a ERROR`, então o Django irá impedir que comandos de gerenciamento sejam exeutados. Mensagens com nível menor que ``ERROR
(ex. alertas) são reportados no console, mas pode ser silenciados.
msg
Uma string curta (menor que 80 caracetres) descrevendo o problema. A string não deve conter outras linhas.
hint
Uma string de uma única linha que forneça uma dica para arrumar o problema. Se não pode ser fornecida uma dica, ou a dica é auto-evidente baseado na mensagem de erro, a dica pode ser omitida, ou o valor None
pode ser usado.
obj
Opcional. Um objeto que fornece contexto para a mensagem (por exemplo, o modelo onde o problema foi descoberto). O objeto deve ser um modelo, campo ou gerenciador ou qualquer outro objeto que defina um método __str__()
. O método é usado durante a exibição de todas as mensagens e seu resultado precede a mensagem.
id
String opcional. Um identificador único para esse problema. Identificadores devem seguir o formato padrão applabel.X001
, onde X
é uma das letras de CEWID
, indicando a gravidade da mensagem (C
para crítico, E
para erro e assim por diante). O número pode ser alocado pela aplicação, mas deve ser único dentro daquela aplicação.
Existem subclasses para tornar a criação de mensagens de níveis comuns mais fácil. Quando usá-los você pode omitir o argumento level
porque ele está implícito no nome da classe.
As seguintes checagens verificarão seu setup para Suporte assíncrono:
async.E001: Você não deve definir a variável de ambiente DJANGO_ALLOW_ASYNC_UNSAFE
em produção. Isso desabilita a proteção de segurança assíncrona.
Testes de compatibilidade notificam sobre problemas que podem ocorrer após atualizar o Django.
2_0.W001: Sua URL <pattern>
tem um route
que contém (?P<
, começa com um ^
ou termina com um $
. Isso provavelmente foi um descuido ao migrar de url()
para path()
.
4_0.E001: A partir do Django 4.0, os valores na configuração CSRF_TRUSTED_ORIGINS
devem começar com um esquema (geralmente http://
ou https://
), mas foi encontrado <hostname>
.
As verificações seguintes averiguam se seu CACHES
está configurado corretamente:
caches.E001: Você deve definir um cache 'default'
para a definição de CACHES
.
caches.W002: Sua configuração <cache>
pode expor o seu cache ou levar à corrupção dos seus dados porque a LOCATION
<CACHES-LOCATION> coincide/está dentro/contém a MEDIA_ROOT
/STATIC_ROOT
/STATICFILES_DIRS
.
caches.W003: Your <cache>
cache LOCATION
is relative. Use an absolute path instead.
If you’re using MySQL or MariaDB, the following checks will be performed:
mysql.E001: MySQL/MariaDB does not allow unique CharField
s to have a
max_length
> 255. This check was changed to mysql.W003
in Django
3.1 as the real maximum size depends on many factors.
mysql.W002: MySQL/MariaDB Strict Mode is not set for database connection
<alias>
. See also Setting sql_mode.
mysql.W003: MySQL/MariaDB may not allow unique CharField
s to have a
max_length
> 255.
The following checks verify your setup for Gerenciando arquivos:
files.E001: The FILE_UPLOAD_TEMP_DIR
setting refers to the
nonexistent directory <path>
.
fields.E001: Nomes de campos não devem terminar com “underscore”.
fields.E002: nome de campos não devem conter "__"
.
fields.E003: pk
é uma palavra reservada que não pode ser usada como nome de campo.
fields.E004: choices
must be a mapping (e.g. a dictionary) or an
iterable (e.g. a list or tuple).
fields.E005: choices
must be a mapping of actual values to human
readable names or an iterable containing (actual value, human readable
name)
tuples.
fields.E006: db_index
deve ser None
, True
ou False
.
fields.E007: Chaves-primárias não devem ter null=True
.
fields.E008: All validators
must be callable.
fields.E009: max_length
is too small to fit the longest value in
choices
(<count>
characters).
fields.E010: <field>
default should be a callable instead of an
instance so that it’s not shared between all field instances.
fields.E011: <database>
does not support default database values with
expressions (db_default
).
fields.E012: <expression>
cannot be used in db_default
.
fields.E013: CompositePrimaryKey
must be named pk
.
fields.E100: AutoField
s devem setar primary_key=True.
fields.E110: BooleanField
s do not accept null values. This check
appeared before support for null values was added in Django 2.1.
fields.E120: CharField
s deve definir um atributo max_length
.
fields.E121: max_length
deve ser um inteiro positivo.
fields.W122: max_length
is ignored when used with
<integer field type>
.
fields.E130: DecimalField
s deve definir um atributo decimal_places
.
fields.E131: decimal_places
deve ser um inteiro não negativo.
fields.E132: DecimalField
s deve ter um atributo max_digits
.
fields.E133: max_digits
must be a positive integer.
fields.E134: max_digits
deve ser igual ou maior que decimal_places
.
fields.E140: FilePathField
s deve ter allow_files
ou allow_folders
definidos como True.
fields.E150: GenericIPAddressField
s cannot have blank=True
if
null=False
, as blank values are stored as nulls.
fields.E160: As opções auto_now
, auto_now_add
, e default
são mutualmente exclusivas. Somente uma destas opções deve estar presente.
fields.W161: Fornecido um valor fixo padrão.
fields.W162: <database>
does not support a database index on
<field data type>
columns.
fields.W163: <database>
does not support comments on columns
(db_comment
).
fields.E170: BinaryField
’s default
cannot be a string. Use bytes
content instead.
fields.E180: <database>
does not support JSONField
s.
fields.E190: <database>
does not support a database collation on
<field_type>
s.
fields.E220: <database>
does not support GeneratedField
s.
fields.E221: <database>
does not support non-persisted
GeneratedField
s.
fields.E222: <database>
does not support persisted
GeneratedField
s.
fields.E223: GeneratedField.output_field
has errors: …
fields.W224: GeneratedField.output_field
has warnings: …
fields.E900: IPAddressField
foi removido exceto para suportar migrações históricas.
fields.W900: IPAddressField
está obsoleto. O suporte para este (exceto para histórico de migrações) será removido no Django 1.9. Esta verificação apareceu em Django 1.7 and 1.8.
fields.W901: CommaSeparatedIntegerField
has been deprecated. Support
for it (except in historical migrations) will be removed in Django 2.0. This
check appeared in Django 1.10 and 1.11.
fields.E901: CommaSeparatedIntegerField
is removed except for support
in historical migrations.
fields.W902: FloatRangeField
is deprecated and will be removed in
Django 3.1. This check appeared in Django 2.2 and 3.0.
fields.W903: NullBooleanField
is deprecated. Support for it (except
in historical migrations) will be removed in Django 4.0. This check appeared
in Django 3.1 and 3.2.
fields.E903: NullBooleanField
is removed except for support in
historical migrations.
fields.W904: django.contrib.postgres.fields.JSONField
is deprecated.
Support for it (except in historical migrations) will be removed in Django
4.0. This check appeared in Django 3.1 and 3.2.
fields.E904: django.contrib.postgres.fields.JSONField
is removed
except for support in historical migrations.
fields.W905: django.contrib.postgres.fields.CICharField
is
deprecated. Support for it (except in historical migrations) will be removed
in Django 5.1. This check appeared in Django 4.2 and 5.0.
fields.E905: django.contrib.postgres.fields.CICharField
is removed
except for support in historical migrations.
fields.W906: django.contrib.postgres.fields.CIEmailField
is
deprecated. Support for it (except in historical migrations) will be removed
in Django 5.1. This check appeared in Django 4.2 and 5.0.
fields.E906: django.contrib.postgres.fields.CIEmailField
is removed
except for support in historical migrations.
fields.W907: django.contrib.postgres.fields.CITextField
is
deprecated. Support for it (except in historical migrations) will be removed
in Django 5.1. This check appeared in Django 4.2 and 5.0.
fields.E907: django.contrib.postgres.fields.CITextField
is removed
except for support for historical migrations.
fields.E200: unique
não é um argumento válido para FileField
. Esta verificação foi removida no Django 1.11.
fields.E201: primary_key
não é um argumento válido para um FileField
.
fields.E202: FileField
’s upload_to
argument must be a relative
path, not an absolute path.
fields.E210: Não é possível usar ImageField
porque o Pillow não está instalado.
models.E001: <swappable>
não está no formato app_label.app_name
.
models.E002: <SETTING>
referencia <model>
, o qual nao foi instalado, ou é abstrato.
models.E003: The model has two identical many-to-many relations through
the intermediate model <app_label>.<model>
.
models.E004: id
somente pode ser usado como nome de um campo se o campo também definir primary_key=True
.
models.E005: O campo <field name>
do modelo pai <model>
colide com o campo <field name>
do modelo pai <model>
.
models.E006: The field <field name>
clashes with the field
<field name>
from model <model>
.
models.E007: Campo <field name>
tem o nome de coluna <column name>
que é usado por outro campo.
models.E008: index_together
must be a list or tuple. This check
appeared before Django 5.1.
models.E009: All index_together
elements must be lists or tuples.
This check appeared before Django 5.1.
models.E010: unique_together
deve ser uma lista de tuplas.
models.E011: Todos os elementos de unique_together
devem ser uma lista de tuplas.
models.E012: constraints/indexes/unique_together
refers to the
nonexistent field <field name>
.
models.E013: constraints/indexes/unique_together
refers to a
ManyToManyField
<field name>
, but ManyToManyField
s are not
supported for that option.
models.E014: ordering
deve ser uma tupla ou listat (mesmo que você queira ordernar por um único campo).
models.E015: ordering
refers to the nonexistent field, related field,
or lookup <field name>
.
models.E016: constraints/indexes/unique_together
refers to field
<field_name>
which is not local to model <model>
.
models.E017: O modelo proxy <model>
cotém campos de modelo.
models.E018: Nome de coluna gerado automaticamente é muito longo para o campo <field>
. O comprimento máximo é <maximum length>
para o banco de dados <alias>
.
models.E019: Nome de campo gerado automaticamente para o campo M2M <M2M field>
é muito longo. O comprimento máximo é <maximum length>
para o banco de dados <alias>
.
models.E020: The <model>.check()
método da classe está neste momento sobrescrito.
models.E021: ordering
e order_with_respect_to
não podem ser usados juntos.
models.E022: <function>
contains a lazy reference to
<app label>.<model>
, but app <app label>
isn’t installed or
doesn’t provide model <model>
.
models.E023: The model name <model>
cannot start or end with an
underscore as it collides with the query lookup syntax.
models.E024: The model name <model>
cannot contain double underscores
as it collides with the query lookup syntax.
models.E025: The property <property name>
clashes with a related
field accessor.
models.E026: The model cannot have more than one field with
primary_key=True
.
models.W027: <database>
does not support check constraints.
models.E028: db_table
<db_table>
is used by multiple models:
<model list>
.
models.E029: index name <index>
is not unique for model <model>
.
models.E030: index name <index>
is not unique among models:
<model list>
.
models.E031: constraint name <constraint>
is not unique for model
<model>
.
models.E032: constraint name <constraint>
is not unique among
models: <model list>
.
models.E033: The index name <index>
cannot start with an underscore
or a number.
models.E034: The index name <index>
cannot be longer than
<max_length>
characters.
models.W035: db_table
<db_table>
is used by multiple models:
<model list>
.
models.W036: <database>
does not support unique constraints with
conditions.
models.W037: <database>
does not support indexes with conditions.
models.W038: <database>
does not support deferrable unique
constraints.
models.W039: <database>
does not support unique constraints with
non-key columns.
models.W040: <database>
does not support indexes with non-key
columns.
models.E041: constraints
refers to the joined field <field name>
.
models.E042: <field name>
cannot be included in the composite
primary key.
models.W042: Auto-created primary key used when not defining a primary
key type, by default django.db.models.AutoField
.
models.W043: <database>
does not support indexes on expressions.
models.W044: <database>
does not support unique constraints on
expressions.
models.W045: Check constraint <constraint>
contains RawSQL()
expression and won’t be validated during the model full_clean()
.
models.W046: <database>
does not support comments on tables
(db_table_comment
).
models.W047: <database>
does not support unique constraints with
nulls distinct.
models.E048: constraints/indexes/unique_together
refers to a
CompositePrimaryKey
<field name>
, but CompositePrimaryKey
s are
not supported for that option.
The following checks verify custom management commands are correctly configured:
commands.E001: The migrate
and makemigrations
commands must have
the same autodetector
.
The security checks do not make your site secure. They do not audit code, do intrusion detection, or do anything particularly complex. Rather, they help perform an automated, low-hanging-fruit checklist, that can help you to improve your site’s security.
Algumas dessas verificações talvez não sejam apropriadas para uma configuração de implantação particular. Por exemlo, se você faz redirecionamento do HTTP para HTTPS em um balanceador de carga, isso pode ser irritante de ser constantemente alertado sobre não ter habilitado o SECURE_SSL_REDIRECT
. Use o SILENCED_SYSTEM_CHECKS
para silenciar verificações desnecessárias.
As seguintes verificações são executadas se você usa a opção check --deploy
:
security.W001: You do not have
django.middleware.security.SecurityMiddleware
in your
MIDDLEWARE
so the SECURE_HSTS_SECONDS
,
SECURE_CONTENT_TYPE_NOSNIFF
, SECURE_REFERRER_POLICY
,
SECURE_CROSS_ORIGIN_OPENER_POLICY
, and
SECURE_SSL_REDIRECT
settings will have no effect.
security.W002: You do not have
django.middleware.clickjacking.XFrameOptionsMiddleware
in your
MIDDLEWARE
, so your pages will not be served with an
'x-frame-options'
header. Unless there is a good reason for your
site to be served in a frame, you should consider enabling this
header to help prevent clickjacking attacks.
security.W003: You don’t appear to be using Django’s built-in cross-site
request forgery protection via the middleware
(django.middleware.csrf.CsrfViewMiddleware
is not in your
MIDDLEWARE
). Enabling the middleware is the safest
approach to ensure you don’t leave any holes.
security.W004: Você não definiu um valor para a definição de SECURE_HSTS_SECONDS
. Se todo o seu site é servido via SSL, talvez queira considerar definir o valor e habilitar HTTP Strict Transport Security. Tenha certeza de ler a documentação primeiro; habilitando HSTS sem cuidados você pode causar problema sérios e irreversíveis.
security.W005: Você não definiu a definição de SECURE_HSTS_INCLUDE_SUBDOMAINS
para True
. Sem isso, seu site está pontencialmente vulnerável a ataques através de uma conexão insegura para um subdomínio. Somente definica como True
se você está certo de que todos os subdomínios do seu domínio devem ser servidos exclusivamente via SSL.
security.W006: Your SECURE_CONTENT_TYPE_NOSNIFF
setting is not
set to True
, so your pages will not be served with an
'X-Content-Type-Options: nosniff'
header. You should consider enabling
this header to prevent the browser from identifying content types incorrectly.
security.W007: Your SECURE_BROWSER_XSS_FILTER
setting is not
set to True
, so your pages will not be served with an
'X-XSS-Protection: 1; mode=block'
header. You should consider enabling
this header to activate the browser’s XSS filtering and help prevent XSS
attacks. This check is removed in Django 3.0 as the X-XSS-Protection
header is no longer honored by modern browsers.
security.W008: Sua definição para SECURE_SSL_REDIRECT
não é True
. A menos que seu site deva estar disponível tanto para conexões SSL quanto para não SSL, você talvez queira definir este como True
ou configurar o balanceador de carga ou o servidor de proxy reverso para redirecionar todas as conexões para HTTPS.
security.W009: Your SECRET_KEY
has less than 50 characters,
less than 5 unique characters, or it’s prefixed with 'django-insecure-'
indicating that it was generated automatically by Django. Please generate a
long and random value, otherwise many of Django’s security-critical features
will be vulnerable to attack.
security.W010: Você tem django.contrib.sessions
no seu INSTALLED_APPS
mas não definiu SESSION_COOKIE_SECURE
como True
. Usando uma “cookie” de sessão “somente-segura” é mais difícil para um “sniffer” de tráfego de rede capturar sessões do usuário.
security.W011: You have
django.contrib.sessions.middleware.SessionMiddleware
in your
MIDDLEWARE
, but you have not set SESSION_COOKIE_SECURE
to True
. Using a secure-only session cookie makes it more difficult for
network traffic sniffers to hijack user sessions.
security.W012: SESSION_COOKIE_SECURE
não é True
. Usando uma “cookie” de sessão como “somente-segura” é mais difícil para um “sniffer” de tráfego de rede capturar sessões do usuário.
security.W013: Você django.contrib.sessions
no seu INSTALLED_APPS
, mas não definiu SESSION_COOKIE_HTTPONLY
como True
. Usando uma “cookie” de sessão HttpOnly
faz com que seja mais difícil um ataque de script extra-site capturar sessões de usuários.
security.W014: You have
django.contrib.sessions.middleware.SessionMiddleware
in your
MIDDLEWARE
, but you have not set SESSION_COOKIE_HTTPONLY
to True
. Using an HttpOnly
session cookie makes it more difficult for
cross-site scripting attacks to hijack user sessions.
security.W015: SESSION_COOKIE_HTTPONLY
não está definido como True
. Usando uma cookie de sessão como HttpOnly
torna mais difícil um ataque de script extra-site capturar sessões de usuários.
security.W016: CSRF_COOKIE_SECURE
não está como True
. Usando a “secure-only” para a “cookie” CSRF torna mais difícil para um “sniffer” de tráfego de rede roubar o token CSRF.
security.W017: CSRF_COOKIE_HTTPONLY
is not set to True
.
Using an HttpOnly
CSRF cookie makes it more difficult for cross-site
scripting attacks to steal the CSRF token. This check is removed in Django
1.11 as the CSRF_COOKIE_HTTPONLY
setting offers no practical
benefit.
security.W018: Você não deve definir DEBUG
como True
em produção.
security.W019: You have
django.middleware.clickjacking.XFrameOptionsMiddleware
in your
MIDDLEWARE
, but X_FRAME_OPTIONS
is not set to
'DENY'
. Unless there is a good reason for your site to serve other parts
of itself in a frame, you should change it to 'DENY'
.
security.W020: ALLOWED_HOSTS
não deve estar vazio durante a implantação.
security.W021: You have not set the
SECURE_HSTS_PRELOAD
setting to True
. Without this, your site
cannot be submitted to the browser preload list.
security.W022: You have not set the SECURE_REFERRER_POLICY
setting. Without this, your site will not send a Referrer-Policy header. You
should consider enabling this header to protect user privacy.
security.E023: You have set the SECURE_REFERRER_POLICY
setting
to an invalid value.
security.E024: You have set the
SECURE_CROSS_ORIGIN_OPENER_POLICY
setting to an invalid value.
security.W025: Your
SECRET_KEY_FALLBACKS[n]
has less than 50
characters, less than 5 unique characters, or it’s prefixed with
'django-insecure-'
indicating that it was generated automatically by
Django. Please generate a long and random value, otherwise many of Django’s
security-critical features will be vulnerable to attack.
The following checks verify that your security-related settings are correctly configured:
security.E100: DEFAULT_HASHING_ALGORITHM
must be 'sha1'
or
'sha256'
. This check appeared in Django 3.1 and 3.2.
security.E101: The CSRF failure view 'path.to.view'
does not take the
correct number of arguments.
security.E102: The CSRF failure view 'path.to.view'
could not be
imported.
signals.E001: <handler>
was connected to the <signal>
signal with
a lazy reference to the sender <app label>.<model>
, but app <app label>
isn’t installed or doesn’t provide model <model>
.
As verificações seguintes averiguam se sua definição de TEMPLATES
está corretamente configurada.
templates.E001: You have 'APP_DIRS': True
in your
TEMPLATES
but also specify 'loaders'
in OPTIONS
. Either
remove APP_DIRS
or remove the 'loaders'
option. This check is
removed in Django 5.1 as system checks may now raise
ImproperlyConfigured
instead.
templates.E002: string_if_invalid
in TEMPLATES
OPTIONS
must be a string but got: {value}
({type}
).
templates.E003:<name>
is used for multiple template tag modules:
<module list>
. This check was changed to templates.W003
in Django
4.1.2.
templates.W003:<name>
is used for multiple template tag modules:
<module list>
.
The following checks are performed on your translation configuration:
translation.E001: You have provided an invalid value for the
LANGUAGE_CODE
setting: <value>
.
translation.E002: You have provided an invalid language code in the
LANGUAGES
setting: <value>
.
translation.E003: You have provided an invalid language code in the
LANGUAGES_BIDI
setting: <value>
.
translation.E004: You have provided a value for the
LANGUAGE_CODE
setting that is not in the LANGUAGES
setting.
As verificações seguintes são realizadas na sua configuração de URL:
urls.W001: Your URL pattern <pattern>
uses
include()
with a route
ending with a $
. Remove the
dollar from the route
to avoid problems including URLs.
urls.W002: Your URL pattern <pattern>
has a route
beginning with
a /
. Remove this slash as it is unnecessary. If this pattern is targeted
in an include()
, ensure the include()
pattern has a trailing /
.
urls.W003: Seu formato padrão de <pattern>
tem um name
incluindo um :
. Remova os dois-pontos para evitar referências anbíguas de domínios baseados em nomes.
urls.E004: Your URL pattern <pattern>
is invalid. Ensure that
urlpatterns
is a list of path()
and/or
re_path()
instances.
urls.W005: URL namespace <namespace>
isn’t unique. You may not be
able to reverse all URLs in this namespace.
urls.E006: The MEDIA_URL
/ STATIC_URL
setting must
end with a slash.
urls.E007: The custom handlerXXX
view 'path.to.view'
does not
take the correct number of arguments (…).
urls.E008: The custom handlerXXX
view 'path.to.view'
could not be
imported.
urls.E009: Your URL pattern <pattern>
has an invalid view, pass
<view>.as_view()
instead of <view>
.
urls.W010: Your URL pattern <pattern>
has an unmatched
<angle bracket>
.
contrib
app checks¶admin
¶Verificações do Admin são todas realizadas como parte da etiqueta admin
.
As seguintes verificações sào realizadas em qualquer ModelAdmin
(ou subclasse) que está registrada com o site Admin:
admin.E001: O valor de raw_id_fields
deve ser uma lista de tuplas.
admin.E002: The value of raw_id_fields[n]
refers to <field name>
,
which is not a field of <model>
.
admin.E003: O valor de raw_id_fields[n]
deve ser uma chave estrangeira ou m campo muitos-para-muitos.
admin.E004: O valor do fields
deve ser uma lista de tuplas.
admin.E005: Ambos fieldsets
e fields
são especificados.
admin.E006: O valor do fields
contém campo(s) duplicados.
admin.E007: O valor do fieldsets
deve ser uma lista de tuplas.
admin.E008: O valor do fieldsets[n]
deve ser uma lista de tuplas.
admin.E009: O valor do fieldsets[n]
deve ter o comprimento igual a 2.
admin.E010: O valor do fieldsets[n][1]
deve ser um dicionário.
admin.E011: O valor do fieldsets[n][1]
deve conter a chave fields
.
admin.E012: Existem campo(s) ducplicados em fieldsets[n][1]
.
admin.E013: The value of
fields[n]/filter_horizontal[n]/filter_vertical[n]/fieldsets[n][m]
cannot
include the ManyToManyField
<field name>
, because that field manually
specifies a relationship model.
admin.E014: O valor do exclude
deve ser uma lista de tuplas.
admin.E015: O valor do exclude
contém campos duplicado(s).
admin.E016: O valor do form
deve herdar de BaseModelForm
.
admin.E017: O valor do filter_vertical
deve ser uma lista de tuplas.
admin.E018: O valor de filter_horizontal
deve ser uma lista de tuplas.
admin.E019: The value of filter_vertical[n]/filter_horizontal[n]
refers to <field name>
, which is not a field of <model>
.
admin.E020: The value of filter_vertical[n]/filter_horizontal[n]
must be a many-to-many field.
admin.E021: O valor de radio_fields
deve ser um dicionário.
admin.E022: The value of radio_fields
refers to <field name>
,
which is not a field of <model>
.
admin.E023: The value of radio_fields
refers to <field name>
,
which is not an instance of ForeignKey
, and does not have a choices
definition.
admin.E024: O valor de radio_fields[<field name>]
deve ser admin.HORIZONTAL
ou admin.VERTICAL
.
admin.E025: O valor de view_on_site
deve ser um “callable” ou um booleano.
admin.E026: O valor de prepopulated_fields
deve ser um dicionário.
admin.E027: The value of prepopulated_fields
refers to
<field name>
, which is not a field of <model>
.
admin.E028: The value of prepopulated_fields
refers to
<field name>
, which must not be a DateTimeField
, a ForeignKey
,
a OneToOneField
, or a ManyToManyField
field.
admin.E029: O valor de prepopulated_fields[<field name>]
deve ser uma lista de tuplas.
admin.E030: The value of prepopulated_fields
refers to
<field name>
, which is not a field of <model>
.
admin.E031: O valor de ordering
deve ser uma lista de tuplas.
admin.E032: O valor de ordering
tem o operador para ordem randômica ?
, mas contém outros campos também.
admin.E033: The value of ordering
refers to <field name>
, which
is not a field of <model>
.
admin.E034: O valor de readonly_fields
deve ser uma lista de tuplas.
admin.E035: The value of readonly_fields[n]
refers to
<field_name>
, which is not a callable, an attribute of
<ModelAdmin class>
, or an attribute of <model>
.
admin.E036: The value of autocomplete_fields
must be a list or tuple.
admin.E037: The value of autocomplete_fields[n]
refers to
<field name>
, which is not a field of <model>
.
admin.E038: The value of autocomplete_fields[n]
must be a foreign
key or a many-to-many field.
admin.E039: An admin for model <model>
has to be registered to be
referenced by <modeladmin>.autocomplete_fields
.
admin.E040: <modeladmin>
must define search_fields
, because
it’s referenced by <other_modeladmin>.autocomplete_fields
.
ModelAdmin
¶A verificações seguintes são realizadas para qualquer ModelAdmin
que é registrada com site Admin:
admin.E101: O valor de save_as
deve ser um booleano.
admin.E102: O valor de save_on_top
deve ser um booleano.
admin.E103: O valor de inlines
deve ser uma lista de tuplas.
admin.E104: <InlineModelAdmin class>
must inherit from
InlineModelAdmin
.
admin.E105: <InlineModelAdmin class>
deve ter um atributo model
.
admin.E106: O valor de <InlineModelAdmin class>.model
deve ser um Model
.
admin.E107: O valor de list_display
deve ser uma lista de tuplas.
admin.E108: The value of list_display[n]
refers to <label>
, which
is not a callable or attribute of <ModelAdmin class>
, or an attribute,
method, or field on <model>
.
admin.E109: The value of list_display[n]
must not be a many-to-many
field or a reverse foreign key.
admin.E110: O valor de list_display_links
deve ser uma lista, uma tupla, ou None
.
admin.E111: O valor de list_display_links[n]
referencia a <label>
, o qual não é definido na list_display
.
admin.E112: O valor de list_filter
deve ser uma lista de tuplas.
admin.E113: O valor de list_filter[n]
deve herdar de ListFilter
.
admin.E114: O valor de list_filter[n]
não deve herdar de FieldListFilter
.
admin.E115: O valor de list_filter[n][1]
deve herdar de FieldListFilter
.
admin.E116: O valor de list_filter[n]
refere a <label>
, o qual não refere a um campo.
admin.E117: O valor de list_select_related
deve ser um booleano, tuplas ou lista.
admin.E118: O valor de list_per_page
deve ser um inteiro.
admin.E119: O valor de list_max_show_all
deve ser um inteiro.
admin.E120: O valor de list_editable
deve ser uma lista de tuplas.
admin.E121: The value of list_editable[n]
refers to <label>
,
which is not a field of <model>
.
admin.E122: O valor de list_editable[n]
refere a <label>
, o qual não está contido em list_display
.
admin.E123: O valor de list_editable[n]
não pode estar em ambos list_editable
e list_display_links
.
admin.E124: O valor de list_editable[n]
refere ao primeiro campo em list_display
(<label>
), o qual não pode ser usado a menos que list_display_links
seja definido.
admin.E125: O valor de list_editable[n]
refere a <field name>
, o qual não é editável através do admin.
admin.E126: O valor de search_fields
deve ser uma lista de tuplas.
admin.E127: The value of date_hierarchy
refers to <field name>
,
which does not refer to a Field.
admin.E128: O valor de date_hierarchy
deve ser um DateField
ou DateTimeField
.
admin.E129: <modeladmin>
must define a has_<foo>_permission()
method for the <action>
action.
admin.E130: __name__
attributes of actions defined in
<modeladmin>
must be unique. Name <name>
is not unique.
InlineModelAdmin
¶As verificações seguintes são realizadas em qualquer InlineModelAdmin
que esteja registrado como uma “inline” na ModelAdmin
.
admin.E201: Não pode excluir o campo <field name>
, porque ele é a chave-estrangeira para o modelo <app_label>.<model>
.
admin.E202: <model>
has no ForeignKey
to <parent model>
./
<model>
has more than one ForeignKey
to <parent model>
. You must
specify a fk_name
attribute.
admin.E203: O valor de extra
deve ser um inteiro.
admin.E204: O valor de max_num
deve ser um inteiro.
admin.E205: O valor de min_num
deve ser um inteiro.
admin.E206: O valor de formset
deve herdar de BaseModelFormSet
.
GenericInlineModelAdmin
¶As seguintes verificações são realizadas sobre qualquer GenericInlineModelAdmin
que esteja registrado como “inline” no ModelAdmin
.
admin.E301: 'ct_field'
referencia a <label>
, o qual não é um campo no <model>
.
admin.E302: 'ct_fk_field'
referencia <label>
, o qual não é um campo no <model>
.
admin.E303: <model>
não tem GenericForeignKey
.
admin.E304: <model>
não tem GenericForeignKey
usando o campo de tipo de conteúdo <field name>
e um campo de ID do objeto <field name>
.
AdminSite
¶As seguintes verificações são realizadas na AdminSite
: padrão
admin.E401: django.contrib.contenttypes
must be in
INSTALLED_APPS
in order to use the admin application.
admin.E402: django.contrib.auth.context_processors.auth
must be enabled in DjangoTemplates
(TEMPLATES
) if using the default auth backend in order to use the
admin application.
admin.E403: A django.template.backends.django.DjangoTemplates
instance must be configured in TEMPLATES
in order to use the
admin application.
admin.E404: django.contrib.messages.context_processors.messages
must be enabled in DjangoTemplates
(TEMPLATES
) in order to use the admin application.
admin.E405: django.contrib.auth
must be in
INSTALLED_APPS
in order to use the admin application.
admin.E406: django.contrib.messages
must be in
INSTALLED_APPS
in order to use the admin application.
admin.E408:
django.contrib.auth.middleware.AuthenticationMiddleware
must be in
MIDDLEWARE
in order to use the admin application.
admin.E409: django.contrib.messages.middleware.MessageMiddleware
must be in MIDDLEWARE
in order to use the admin application.
admin.E410: django.contrib.sessions.middleware.SessionMiddleware
must be in MIDDLEWARE
in order to use the admin application.
admin.W411: django.template.context_processors.request
must be
enabled in DjangoTemplates
(TEMPLATES
) in order to use the admin navigation sidebar.
auth
¶auth.E001: REQUIRED_FIELDS
deve ser uma lista de tuplas.
auth.E002: O campo definido como USERNAME_FIELD
para um modelo de usuário personalizado não deve ser incluído no REQUIRED_FIELDS
.
auth.E003: <field>
deve ser único porque ele está definido como USERNAME_FIELD
.
auth.W004: <field>
é definido como o USERNAME_FIELD
, mas não é único.
auth.E005: The permission codenamed <codename>
clashes with a builtin
permission for model <model>
.
auth.E006: The permission codenamed <codename>
is duplicated for model
<model>
.
auth.E007: The verbose_name
of model <model>
must be at most
244 characters for its builtin permission names
to be at most 255 characters.
auth.E008: The permission named <name>
of model <model>
is longer
than 255 characters.
auth.C009: <User model>.is_anonymous
must be an attribute or property
rather than a method. Ignoring this is a security issue as anonymous users
will be treated as authenticated!
auth.C010: <User model>.is_authenticated
must be an attribute or
property rather than a method. Ignoring this is a security issue as anonymous
users will be treated as authenticated!
auth.E011: The name of model <model>
must be at most 93 characters
for its builtin permission names to be at most 100 characters.
auth.E012: The permission codenamed <codename>
of model <model>
is longer than 100 characters.
auth.E013: In order to use
django.contrib.auth.middleware.LoginRequiredMiddleware
,
django.contrib.auth.middleware.AuthenticationMiddleware
must be
defined before it in MIDDLEWARE.
contenttypes
¶As verificação seguintes são realizadas quando um modelo contém um GenericForeignKey
ou GenericRelation
:
contenttypes.E001: The GenericForeignKey
object ID references the
nonexistent field <field>
.
contenttypes.E002: The GenericForeignKey
content type references the
nonexistent field <field>
.
contenttypes.E003: <field>
não é uma ForeignKey
.
contenttypes.E004: <field>
não é uma ForeignKey
para contenttypes.ContentType
.
contenttypes.E005: Model names must be at most 100 characters.
postgres
¶The following checks are performed on django.contrib.postgres
model
fields:
postgres.E001: Base field for array has errors: …
postgres.E002: Base field for array cannot be a related field.
postgres.E003: <field>
default should be a callable instead of an
instance so that it’s not shared between all field instances. This check was
changed to fields.E010
in Django 3.1.
postgres.W004: Base field for array has warnings: …
sites
¶As verificações seguintes são realizadas em qualquer modelo usando uma CurrentSiteManager
:
sites.E001: CurrentSiteManager
não pode achar um campo chamado <field name>
.
sites.E002: CurrentSiteManager
cannot use <field>
as it is not a
foreign key or a many-to-many field.
The following checks verify that django.contrib.sites
is correctly
configured:
sites.E101: The SITE_ID
setting must be an integer.
staticfiles
¶The following checks verify that django.contrib.staticfiles
is correctly
configured:
staticfiles.E001: The STATICFILES_DIRS
setting is not a tuple
or list.
staticfiles.E002: The STATICFILES_DIRS
setting should not
contain the STATIC_ROOT
setting.
staticfiles.E003: The prefix <prefix>
in the
STATICFILES_DIRS
setting must not end with a slash.
staticfiles.W004: The directory <directory>
in the
STATICFILES_DIRS
does not exist.
staticfiles.E005: The STORAGES
setting must define a
staticfiles
storage.
abr. 23, 2025