我在我的应用上遇到了这个错误:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/usr/local/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.5/site-packages/django/apps/config.py", line 142, in create
app_module = import_module(app_name)
File "/usr/local/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'sheets'
我的配置文件是:
LOCAL_APPS = (
# custom users app
'sorbetcitron.users.apps.UsersConfig',
# Your stuff: custom apps go here
'sorbetcitron.sheets.apps.SheetsConfig',
'sorbetcitron.cashflows.apps.CashflowsConfig',
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
我的项目目录是:
我的sorbetcitron.sheets.apps.py:
from django.apps import AppConfig
class SheetsConfig(AppConfig):
name = 'sheets
我没有得到的是我的第二个名为“cashflows”的应用程序没有问题。
答案 0 :(得分:0)
AppConfig.name
必须是您的应用程序的路径。在您的代码中,您放置了name = 'sheets'
而不是name = 'sorbetcitron.sheets'
请参阅https://docs.djangoproject.com/en/stable/ref/applications/#for-application-authors