django_tenants 中的警告是否仍然有效?
Is this warning in django_tenants still valid?
在 django_tenants 的 apps.py 中,我看到了这个:
recommended_config = """
Warning: You should put 'django_tenants' at the end of INSTALLED_APPS:
INSTALLED_APPS = TENANT_APPS + SHARED_APPS + ('django_tenants',)
This is necessary to overwrite built-in django management commands with
their schema-aware implementations.
"""
我的问题是:这仍然有效吗?在我碰巧在代码中看到该消息之前,我们已经(在开发中)安装了 django_tenants 几个星期。它在 INSTALLED_APPS 中不是最后一次,但它似乎工作得很好。
如果你想让一个应用覆盖其他应用的管理命令,应该是listed first:
Django registers the built-in commands and then searches for commands in INSTALLED_APPS
in reverse. During the search, if a command name duplicates an already registered command, the newly discovered command overrides the first.
In other words, to override a command, the new command must have the same name and its app must be before the overridden command’s app in INSTALLED_APPS
.
所以那个建议已经过时了(这是 changed 五年前的事)。
请注意 django_tenants 的实际 installation documentation 是 最新的,首先列出 'django_tenants'
:
SHARED_APPS = (
'django_tenants', # mandatory
...
)
INSTALLED_APPS = list(SHARED_APPS) + ...
因此您找到的那行代码可能不相关。
在 django_tenants 的 apps.py 中,我看到了这个:
recommended_config = """
Warning: You should put 'django_tenants' at the end of INSTALLED_APPS:
INSTALLED_APPS = TENANT_APPS + SHARED_APPS + ('django_tenants',)
This is necessary to overwrite built-in django management commands with
their schema-aware implementations.
"""
我的问题是:这仍然有效吗?在我碰巧在代码中看到该消息之前,我们已经(在开发中)安装了 django_tenants 几个星期。它在 INSTALLED_APPS 中不是最后一次,但它似乎工作得很好。
如果你想让一个应用覆盖其他应用的管理命令,应该是listed first:
Django registers the built-in commands and then searches for commands in
INSTALLED_APPS
in reverse. During the search, if a command name duplicates an already registered command, the newly discovered command overrides the first.In other words, to override a command, the new command must have the same name and its app must be before the overridden command’s app in
INSTALLED_APPS
.
所以那个建议已经过时了(这是 changed 五年前的事)。
请注意 django_tenants 的实际 installation documentation 是 最新的,首先列出 'django_tenants'
:
SHARED_APPS = ( 'django_tenants', # mandatory ... ) INSTALLED_APPS = list(SHARED_APPS) + ...
因此您找到的那行代码可能不相关。