首页 文章

我可以让django-oscar在Python 3下工作吗?

提问于
浏览
-1

我正在使用Python 3.6.0,Django 1.10.6和Oscar 1.4.0版本 .

我已经看到类似的错误消息被讨论和报告通过某些解决方案解决(例如更新"still"一个旧的自动生成的wsgi.py),或者添加 import djangodjango.setup() 几乎接近顶部(即在 SECRET_KEYINSTALLED_APPS 之前,向上移动)靠近顶部) . 我发现Github上的错误消息更接近匹配,为了Raven的目的,人们已经全部清除了从他们的项目中删除标准用户或认证模块 . 但是,我还没有找到有人报告错误的地方,除了全明确的解决方案之外,还有一个解决方案是从一个不相关的基于Django的项目中删除一个标准的Django应用程序 .

特定的错误消息和跟踪并没有向我大声说明哪个行存在问题,而不是怀疑它是由INSTALLED_APPS中包含'django.contrib.contenttypes'触发的 . 我尝试运行它时得到的跟踪是:

(store-env) ~/store $ python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 342, in execute
    self.check()
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 374, in check
    include_deployment_checks=include_deployment_checks,
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 361, in _run_checks
    return checks.run_checks(**kwargs)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/urls/resolvers.py", line 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/urls/resolvers.py", line 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "/Users/christos/store-env/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/christos/store/store/urls.py", line 18, in <module>
    from oscar.app import application
  File "/Users/christos/store-env/lib/python3.6/site-packages/oscar/app.py", line 5, in <module>
    from django.contrib.auth import views as auth_views
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/auth/views.py", line 11, in <module>
    from django.contrib.auth.forms import (
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 12, in <module>
    from django.contrib.auth.models import User
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/auth/models.py", line 6, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/contenttypes/models.py", line 138, in <module>
    class ContentType(models.Model):
  File "/Users/christos/store-env/lib/python3.6/site-packages/django/db/models/base.py", line 113, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
(store-env) ~/store $

我当前的 settings.py ,从据报道在SO上为其他人工作过的有用或无益的修改,是一个未受影响的 import os

from oscar.defaults import *

from django.conf import settings

settings.configure()

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '[DELETED]'

from oscar import get_core_apps

INSTALLED_APPS = [
    #'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.flatpages',
    'django.contrib.sites.models.Site',
    'django.contrib.contenttypes.models.ContentType',
    'compressor',
    'widget_tweaks'
] + get_core_apps()

import django
django.setup()
"""
Django settings for store project.

Generated by 'django-admin startproject' using Django 1.10.6.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os

我能做什么/我应该做什么,奥斯卡拥有它应该得到的所有应用程序?

1 回答

  • 0
    'django.contrib.sites.models.Site',
    'django.contrib.contenttypes.models.ContentType'
    

    这不应该在已安装的应用程序部分中 . 这些是模型,已安装的应用程序部分主要用于应用程序 .

相关问题