使用django-oscar创建自己的商店时的设置错误

时间:2014-10-25 04:35:24

标签: django-oscar

导致错误的原因是什么?我是django-oscar和django的新手。 谢谢你提前帮助我。这是我的settings.py

#settings.py
from oscar import get_core_apps
from oscar import OSCAR_MAIN_TEMPLATE_DIR
from oscar.defaults import *
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

location = lambda x: os.path.join(
   os.path.dirname(os.path.realpath(__file__)), x
)

SECRET_KEY = 'pa--blableitnhczk5ublsx%)*bla^sox86&*slbs&y'
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []

STATIC_FINDERS = (
    'django.contrib.staticfiles.finders.FilesystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

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',
    'south',
    'compressor',
) + get_core_apps()


SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader',
)
TEMPLATE_DIRS = (
    location('templates'),
    OSCAR_MAIN_TEMPLATE_DIR,
)
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.apps.context_processors.metadata',
)   

AUTHENTICATION_BACKNDS = (
    'oscar.apps.customer.auth_backends.Emailbackend',
    'django.contrib.auth.backends.ModelBackend',
)

HAYSTACK_CONNECTIONS = {
    'default' : {
        'ENGINE' : 'haystack.backends.simple_backend.SimpleEngine',
    },
} 

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    '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.middleware.transaction.TransctionMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
)

ROOT_URLCONF = 'rdyact.urls'
WSGI_APPLICATION = 'rdyact.wsgi.application'
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'USER' : '',
        'PASSWORD' : '',
        'HOST' : '',
        'PORT' : '',
        'ATOMIC_REQUESTS' : True,
    }
}

LANGUAGE_CODE = 'en-us'
SITE_ID = 1
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

STATIC_URL = '/static/'
STATIC_ROOT = ''
STATIC_DIRS = (
)
MEDIA_ROOT = ''
MEDIA_URL = ''

当我输入syncdb或runserver命令时,错误如下所示。 " TypeError:只能将元组(不是" list")连接到元组"

(oscar)ubuntu@ubuntu-VirtualBox:~/oscar/rdyact$ python manage.py syncdb --noinput
  Traceback (most recent call last):
    File "manage.py", line 10, in <module>
      execute_from_command_line(sys.argv)
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
      utility.execute()
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
      commands = get_commands()
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
      apps = settings.INSTALLED_APPS
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
      self._setup(name)
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
      self._wrapped = Settings(settings_module)
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 128, in __init__
      mod = importlib.import_module(self.SETTINGS_MODULE)
    File "/home/ubuntu/oscar/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
      __import__(name)
    File "/home/ubuntu/oscar/rdyact/rdyact/settings.py", line 57, in <module>
      ) + get_core_apps()
  TypeError: can only concatenate tuple (not "list") to tuple

1 个答案:

答案 0 :(得分:1)

如果您使用get_core_apps(),则需要将INSTALLED_APPS列为一个列表,而不是元组。

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',
    'south',
    'compressor',
] + get_core_apps()