Iam在http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html教程的帮助下在django-oscar中创建项目,
我安装了他们在doc中提到的每个包。在我运行我的项目之后(发生服务器错误。请联系管理员。在ui中出现此错误)并且错误抛出终端
File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
return self.application(environ, start_response)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
self.load_middleware()
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 44, in load_middleware
mw_class = import_string(middleware_path)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 26, in import_string
module = import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/apps/basket/middleware.py", line 8, in <module>
Applicator = get_class('offer.utils', 'Applicator')
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 67, in get_class
return get_classes(module_label, [classname])[0]
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 124, in get_classes
oscar_module = _import_module(oscar_module_label, classnames)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 159, in _import_module
return __import__(module_label, fromlist=classnames)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/apps/offer/utils.py", line 10, in <module>
ConditionalOffer = get_model('offer', 'ConditionalOffer')
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 321, in get_model
return apps.get_model(app_label, model_name)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/apps/registry.py", line 202, in get_model
return self.get_app_config(app_label).get_model(model_name.lower())
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/apps/registry.py", line 150, in get_app_config
raise LookupError("No installed app with label '%s'." % app_label)
LookupError: No installed app with label 'offer'.
[23/Mar/2015 07:22:20] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
return self.application(environ, start_response)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
self.load_middleware()
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 44, in load_middleware
mw_class = import_string(middleware_path)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 26, in import_string
module = import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/apps/basket/middleware.py", line 8, in <module>
Applicator = get_class('offer.utils', 'Applicator')
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 67, in get_class
return get_classes(module_label, [classname])[0]
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 124, in get_classes
oscar_module = _import_module(oscar_module_label, classnames)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 159, in _import_module
return __import__(module_label, fromlist=classnames)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/apps/offer/utils.py", line 10, in <module>
ConditionalOffer = get_model('offer', 'ConditionalOffer')
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/oscar/core/loading.py", line 321, in get_model
return apps.get_model(app_label, model_name)
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/apps/registry.py", line 202, in get_model
return self.get_app_config(app_label).get_model(model_name.lower())
File "/home/spericorn/global/oscar/local/lib/python2.7/site-packages/django/apps/registry.py", line 150, in get_app_config
raise LookupError("No installed app with label '%s'." % app_label)
LookupError: No installed app with label 'offer'.
我的settings.py是:
“”” frobshop项目的Django设置。
“”
from oscar.defaults import *
from oscar import OSCAR_MAIN_TEMPLATE_DIR
import os
def root(x):
return os.path.join(os.path.abspath(os.path.dirname(__file__)), '..',x)
SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'compressor',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'oscar.apps.basket.middleware.BasketMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
)
AUTHENTICATION_BACKENDS = (
'oscar.apps.customer.auth_backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
ROOT_URLCONF = 'frobshop.urls'
WSGI_APPLICATION = 'frobshop.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': root( 'db.sqlite3'),
'ATOMIC_REQUESTS': True,
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
SITE_ID = 1
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
'oscar.apps.search.context_processors.search_form',
'oscar.apps.promotions.context_processors.promotions',
'oscar.apps.checkout.context_processors.checkout',
'oscar.apps.customer.notifications.context_processors.notifications',
'oscar.core.context_processors.metadata',
)
MEDIA_ROOT = root('media')
MEDIA_URL = '/media/'
STATIC_ROOT = root('staticstorage')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
root('static'),
)
TEMPLATE_DIRS = [
root('templates'),
OSCAR_MAIN_TEMPLATE_DIR
]
#
# HAYSTACK_CONNECTIONS = {
# 'default': {
# 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
# 'URL': 'http://127.0.0.1:8983/solr',
# 'INCLUDE_SPELLING': True,
# },
# }
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
}
提前致谢,请帮帮我。
答案 0 :(得分:3)
试试这个
from oscar import get_core_apps
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'compressor',
] + get_core_apps()
get_core_apps
将包含
OSCAR_CORE_APPS = [
'oscar',
'oscar.apps.analytics',
'oscar.apps.checkout',
'oscar.apps.address',
'oscar.apps.shipping',
'oscar.apps.catalogue',
'oscar.apps.catalogue.reviews',
'oscar.apps.partner',
'oscar.apps.basket',
'oscar.apps.payment',
'oscar.apps.offer',
'oscar.apps.order',
'oscar.apps.customer',
'oscar.apps.promotions',
'oscar.apps.search',
'oscar.apps.voucher',
'oscar.apps.wishlists',
'oscar.apps.dashboard',
'oscar.apps.dashboard.reports',
'oscar.apps.dashboard.users',
'oscar.apps.dashboard.orders',
'oscar.apps.dashboard.promotions',
'oscar.apps.dashboard.catalogue',
'oscar.apps.dashboard.offers',
'oscar.apps.dashboard.partners',
'oscar.apps.dashboard.pages',
'oscar.apps.dashboard.ranges',
'oscar.apps.dashboard.reviews',
'oscar.apps.dashboard.vouchers',
'oscar.apps.dashboard.communications',
# 3rd-party apps that oscar depends on
'haystack',
'treebeard',
'sorl.thumbnail',
'django_tables2',
]
答案 1 :(得分:0)
你不要导入奥斯卡核心应用程序。您需要导入它们并添加到INSTALLED_APPS。
您可以通过导入from oscar import get_core_apps
get_core_apps
是一个返回(列出)默认和所需的Oscar核心应用程序的函数。
所以你需要连接它。
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'compressor',
] + get_core_apps()
注意:如果您的INSTALLED_APPS是元组(非列表),则会出现错误,因为get_core_apps()
会返回一个列表。因此,您需要将INSTALLED_APPS更改为列表类型。