【问题标题】:Official Django Tutorial Part1: RuntimeError: maximum recursion depth exceeded in cmp官方 Django 教程 Part1: RuntimeError: maximum recursion depth exceeded in cmp
【发布时间】:2013-03-11 10:36:53
【问题描述】:

按照 django 教程,我创建了项目并按照教程中的说明执行了 manage.py runserver,但出现错误“RuntimeError: maximum recursion depth exceeded in cmp”

有什么办法可以改正吗?

我得到了这个错误:

验证模型... 由 > 启动的线程中未处理的异常 回溯(最近一次通话最后): 文件“/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py”,第 92 行,inner_run self.validate(display_num_errors=True) 文件“/Library/Python/2.7/site-packages/django/core/management/base.py”,第 280 行,验证中 num_errors = get_validation_errors(s, app) 文件“/Library/Python/2.7/site-packages/django/core/management/validation.py”,第 35 行,在 get_validation_errors get_app_errors().items() 中的 (app_name, error): 文件“/Library/Python/2.7/site-packages/django/db/models/loading.py”,第 166 行,在 get_app_errors self._populate() _populate 中的文件“/Library/Python/2.7/site-packages/django/db/models/loading.py”,第 72 行 self.load_app(app_name, True) 文件“/Library/Python/2.7/site-packages/django/db/models/loading.py”,第 96 行,在 load_app 模型 = import_module('.models', app_name) 文件“/Library/Python/2.7/site-packages/django/utils/importlib.py”,第 35 行,在 import_module __import__(名称) 文件“/Library/Python/2.7/site-packages/django/contrib/auth/models.py”,第 370 行,在 类 AbstractUser(AbstractBaseUser,PermissionsMixin): __new__ 中的文件“/Library/Python/2.7/site-packages/django/db/models/base.py”,第 213 行 new_class.add_to_class(field.name, copy.deepcopy(field)) 文件“/Library/Python/2.7/site-packages/django/db/models/base.py”,第 265 行,在 add_to_class value.contribute_to_class(cls, 名称) 文件“/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py”,第257行,在contribute_to_class cls._meta.add_field(self) 文件“/Library/Python/2.7/site-packages/django/db/models/options.py”,第 179 行,在 add_field self.local_fields.insert(二分(self.local_fields,字段),字段) 文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py”,第 56 行,在 '__lt__': [('__gt__', lambda self, other: other '__lt__': [('__gt__', lambda self, other: other '__lt__': [('__gt__', lambda self, other: other '__lt__': [('__gt__', lambda self, other: other ......................... RuntimeError:在 cmp 中超出最大递归深度

Settings.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}


ALLOWED_HOSTS = []


TIME_ZONE = 'America/Chicago'


LANGUAGE_CODE = 'en-us'

SITE_ID = 1


USE_I18N = True


USE_L10N = True
USE_TZ = True
MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)


STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

SECRET_KEY = '+8nn@%#%d8r4##x*t==ja=kbm(514bng1m47yesv1wlsu#%)h4'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'mysite.urls'

WSGI_APPLICATION = 'mysite.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)


LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

urls.py

from django.conf.urls import patterns, include, url
home', name='home'),
    # url(r'^mysite/', include('mysite.foo.urls')),
    enter code here
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)

【问题讨论】:

  • 你能粘贴你的模型文件吗?
  • 没有模型文件。我只是按照教程docs.djangoproject.com/en/1.5/intro/tutorial01 标题是开发服务器
  • @TarikSetia,你使用的是什么 django 版本?我想到的第一件事是重新安装 django(可能是你在安装新的 django 之前没有删除旧的 django..)。
  • @CppLearner 执行 python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)" 以获取 django 的路径。然后手动删除。使用 PIP 重新安装

标签: python django


【解决方案1】:

我知道这是一个老问题,但我遇到了同样的错误。将 Python 更新到 v 2.7.5 对我有用。

我在切换帐户但尝试启动同一个 Django 项目时遇到错误,并且我只在第一个帐户上更新了我的 Python 版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    • 1970-01-01
    • 2018-11-29
    • 2021-04-19
    • 1970-01-01
    • 2011-09-07
    相关资源
    最近更新 更多