Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django-oscar错误-Django.core.exceptions.impropertlyconfigured:应用程序标签不';t唯一,重复:静态文件_Python_Django_Ubuntu_Django Oscar - Fatal编程技术网

Python Django-oscar错误-Django.core.exceptions.impropertlyconfigured:应用程序标签不';t唯一,重复:静态文件

Python Django-oscar错误-Django.core.exceptions.impropertlyconfigured:应用程序标签不';t唯一,重复:静态文件,python,django,ubuntu,django-oscar,Python,Django,Ubuntu,Django Oscar,我正在尝试启动Django oscar并按照给出的说明进行操作,但是当我尝试使用python manage.py runserver或python manage.py migrate时,我遇到了以下错误。我不明白这是什么,因为我是Python和Django新手。有人能给出一个解决办法吗? 我正在使用Ubuntu、Python 2.7和Django 1.8 Unhandled exception in thread started by <function wrapper at 0xb681

我正在尝试启动Django oscar并按照给出的说明进行操作,但是当我尝试使用
python manage.py runserver
python manage.py migrate
时,我遇到了以下错误。我不明白这是什么,因为我是Python和Django新手。有人能给出一个解决办法吗? 我正在使用Ubuntu、Python 2.7和Django 1.8

Unhandled exception in thread started by <function wrapper at 0xb681072c>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 107, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 252, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 89, in populate
    "duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: staticfiles
[更新] 按照他的指示,我删除了重复的应用程序,但是,现在,当我使用
migrate

/usr/local/lib/python2.7/dist-packages/haystack/utils/__init__.py:12: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils import importlib

/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py:78: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Site(models.Model):

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 328, in execute
    django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/compressor/models.py", line 1, in <module>
    from compressor.conf import CompressorConf  # noqa
  File "/usr/local/lib/python2.7/dist-packages/compressor/conf.py", line 9, in <module>
    class CompressorConf(AppConf):
  File "/usr/local/lib/python2.7/dist-packages/appconf/base.py", line 75, in __new__
    new_class._configure()
  File "/usr/local/lib/python2.7/dist-packages/appconf/base.py", line 104, in _configure
    value = callback(value)
  File "/usr/local/lib/python2.7/dist-packages/compressor/conf.py", line 91, in configure_root
    'STATIC_ROOT, please define either')
django.core.exceptions.ImproperlyConfigured: COMPRESS_ROOT defaults to STATIC_ROOT, please define either
/usr/local/lib/python2.7/dist-packages/haystack/utils/__________.py:12:removedindjango19警告:django.utils.importlib将在django 1.9中删除。
从django.utils导入importlib
/usr/local/lib/python2.7/dist packages/django/contrib/sites/models.py:78:removedindjango19警告:模型类django.contrib.sites.models.Site没有声明显式的应用程序标签,或者不在已安装的应用程序中,或者在加载应用程序之前导入。Django 1.9不再支持这一点。
班级站点(models.Model):
回溯(最近一次呼叫最后一次):
文件“manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/usr/local/lib/python2.7/dist-packages/django/core/management/__-init__;.py”,第354行,从命令行执行
utility.execute()
文件“/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py”,第328行,在execute中
django.setup()
文件“/usr/local/lib/python2.7/dist-packages/django/_-init__.py”,第18行,在安装程序中
应用程序。填充(设置。已安装的应用程序)
文件“/usr/local/lib/python2.7/dist packages/django/apps/registry.py”,第108行,填充
app_config.import_models(所有_models)
文件“/usr/local/lib/python2.7/dist-packages/django/apps/config.py”,第198行,在import\u模型中
self.models\u module=导入模块(models\u module\u name)
文件“/usr/lib/python2.7/importlib/_init_uuu.py”,第37行,在导入模块中
__导入(名称)
文件“/usr/local/lib/python2.7/dist packages/compressor/models.py”,第1行,在
从compressor.conf导入CompressorConf#noqa
文件“/usr/local/lib/python2.7/dist packages/compressor/conf.py”,第9行,在
压缩类Conf(AppConf):
文件“/usr/local/lib/python2.7/dist packages/appconf/base.py”,第75行,新__
新建_类。_configure()
文件“/usr/local/lib/python2.7/dist-packages/appconf/base.py”,第104行,在
值=回调(值)
文件“/usr/local/lib/python2.7/dist packages/compressor/conf.py”,第91行,在configure_root中
'静态根,请定义其中一个')
django.core.exceptions.impropertlyconfigured:COMPRESS\u ROOT默认为STATIC\u ROOT,请定义

您的
安装的应用程序包含
django.contrib.staticfiles
两次。你应该删除副本

我也遇到了同样的问题,然后我更改了settings.py,如下所示:

# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

#STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'`enter code here`

#MEDIA_ROOT = '/home/myshop/media'

STATICFILES_DIRS = [

    os.path.join(BASE_DIR, '/static/'),

    os.path.join(BASE_DIR, '/media/'),

]

STATIC_ROOT = '/home/myshop/staticfiles'
成功了


顺便说一句,我正在使用python3.5和Django 2.0.9以及oscar 1.5和mysql 5.7。

请检查更新,您的解决方案解决了上述问题,但现在我有了一个新的解决方案。你能看出什么地方出了问题吗?
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
>   'django.contrib.staticfiles',
>   'django.contrib.staticfiles',
    'django.contrib.flatpages',
# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

#STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'`enter code here`

#MEDIA_ROOT = '/home/myshop/media'

STATICFILES_DIRS = [

    os.path.join(BASE_DIR, '/static/'),

    os.path.join(BASE_DIR, '/media/'),

]

STATIC_ROOT = '/home/myshop/staticfiles'