ImportError:Django Oscar中没有名为apps的模块错误 - 同时在INSTALLED_APPS中包含一个应用程序

时间:2015-09-30 16:38:45

标签: python django django-oscar

当我尝试自定义Oscar并在INSTALLED_APPS下添加名为促销的应用时,我收到此错误

(oscar)Macs-MacBook-Air:cyshop Mac$ python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Mac/virtualenvs/oscar/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/Mac/virtualenvs/oscar/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
  File "/Users/Mac/virtualenvs/oscar/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/Mac/virtualenvs/oscar/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/Users/Mac/virtualenvs/oscar/lib/python2.7/site-packages/django/apps/config.py", line 112, in create
    mod = import_module(mod_path)
  File   "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named apps

我不确定是否无法选择我已添加促销活动的应用文件夹。

settings.py看起来像这样:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',
    'compressor',
    'widget_tweaks'
]

from oscar import get_core_apps

INSTALLED_APPS = INSTALLED_APPS + get_core_apps(
['apps.promotions'])

我的文件结构是: | cyshop

|_init_.py

|db.sqlite3

|manage.py

|settings.py

|apps 

     |_init_.py

     |promotions

          |_init_.py

          |models.py

|urls.py

|wsgi.py

请帮帮我。我不确定为什么在将属性添加到get_core_apps()

时会发生ImportError

2 个答案:

答案 0 :(得分:0)

您必须将您的模块(应用程序)Agragar转换为INSTALLED_APPS.Es说

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'compressor',
'widget_tweaks',
"apps",

答案 1 :(得分:0)

还要确保您的应用有 init .py(可能是空白文件)

那是我的问题。我意外删除了该文件,然后我收到了与您相同的错误。

在应用程序的文件夹中创建一个新文件 init .py,将其修复

编辑:我看到你有这个文件。这只是通过搜索偶然发现此问题的其他人的通知。