django - 迁移和模型转换的问题

django - trouble with migrations and modeltranslations

我正在尝试将我的应用程序从 Django v1.6.11 升级到 v1.7.8。我正在关注 instructions to upgrade from South 但一次又一次地遇到同样的错误。更准确地说:

$ python manage.py migrate makemigrations
/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/reversion/admin.py:385: RemovedInDjango18Warning: commit_on_success is deprecated in favor of atomic.
  def recover_view(self, request, version_id, extra_context=None):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/reversion/admin.py:397: RemovedInDjango18Warning: commit_on_success is deprecated in favor of atomic.
  def revision_view(self, request, object_id, version_id, extra_context=None):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/forms/widgets.py:143: RemovedInDjango18Warning: `VersionMetaAdmin.queryset` method should be renamed `get_queryset`.
  .__new__(mcs, name, bases, attrs))

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cms/publisher/manager.py:5: RemovedInDjango18Warning: `PublisherManager.get_query_set` method should be renamed `get_queryset`.
  class PublisherManager(models.Manager):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cms/models/managers.py:15: RemovedInDjango18Warning: `PageManager.get_query_set` method should be renamed `get_queryset`.
  class PageManager(PublisherManager):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cms/admin/change_list.py:39: RemovedInDjango18Warning: `CMSChangeList.get_query_set` method should be renamed `get_queryset`.
  class CMSChangeList(ChangeList):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cms/admin/forms.py:397: RemovedInDjango18Warning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form PagePermissionInlineAdminForm needs updating
  class PagePermissionInlineAdminForm(forms.ModelForm):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cms/admin/forms.py:499: RemovedInDjango18Warning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form ViewRestrictionInlineAdminForm needs updating
  class ViewRestrictionInlineAdminForm(PagePermissionInlineAdminForm):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/cms/admin/forms.py:548: RemovedInDjango18Warning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form PageUserForm needs updating
  class PageUserForm(UserCreationForm, GenericCmsPermissionForm):

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/forms/widgets.py:143: RemovedInDjango18Warning: `PagePermissionInlineAdmin.queryset` method should be renamed `get_queryset`.
  .__new__(mcs, name, bases, attrs))

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/forms/widgets.py:143: RemovedInDjango18Warning: `ViewRestrictionInlineAdmin.queryset` method should be renamed `get_queryset`.
  .__new__(mcs, name, bases, attrs))

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/forms/widgets.py:143: RemovedInDjango18Warning: `PageUserAdmin.queryset` method should be renamed `get_queryset`.
  .__new__(mcs, name, bases, attrs))

/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/template/base.py:290: RemovedInDjango18Warning: 'The `firstof` template tag is changing to escape its arguments; the non-autoescaping version is deprecated. Load it from the `future` tag library to start using the new behavior.
  compiled_result = compile_func(self, token)

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
    self.module.autodiscover()
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 23, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/roberto/workspace/unicms/unicms/unicms/admin.py", line 24, in <module>
    admin.site.register(ResearchArea, ResearchAreaAdmin)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 104, in register
    self._registry[model] = admin_class(model, self)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/modeltranslation/admin.py", line 239, in __init__
    super(TranslationAdmin, self).__init__(*args, **kwargs)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/modeltranslation/admin.py", line 28, in __init__
    self.trans_opts = translator.get_options_for_model(self.model)
  File "/home/roberto/virtualenvs/ve_unicms-django1.7/local/lib/python2.7/site-packages/modeltranslation/translator.py", line 519, in get_options_for_model
    'translation' % model.__name__)
modeltranslation.translator.NotRegistered: The model "ResearchArea" is not registered for translation

在我看来,这是一个 django-modeltranslation 问题。我在他们的网站上检查了 dependencies,我使用的是正确的设置:django 1.7.11,python 2.7.5,django-modeltranslation 0.8.

$ pip freeze
BeautifulSoup==3.2.1
Django==1.7.8
Django-Select2==4.3.1
Fabric==1.10.1
Pillow==2.8.1
South==1.0.2
argparse==1.2.1
cmsplugin-news==0.4.4
django-analytical==0.21.0
django-ckeditor==4.4.7
django-classy-tags==0.6.1
django-cms==3.0.13
django-cookie-law==1.0.2
django-country-dialcode==0.6.1
django-debug-toolbar==1.3.0
django-extensions==1.5.3
django-fabric==2.0.2
django-ga-tracking==0.0.6
django-guardian==1.2.5
django-haystack==2.3.1
django-modeltranslation==0.8
django-mptt==0.6.1
django-redis-cache==0.13.1
django-reusableapps==0.1.1
django-reversion==1.7.1
django-sekizai==0.8.1
django-tinymce==1.5.3
django-treebeard==3.0
djangocms-admin-style==0.2.5
djangocms-file==0.1
djangocms-link==1.6.1
djangocms-picture==0.1
djangocms-text-ckeditor==2.4.3
djangocms-video==0.1
easy-thumbnails==2.2
ecdsa==0.13
elasticsearch==1.4.0
feedparser==5.2.0
hiredis==0.2.0
html5lib==0.99999
paramiko==1.15.2
psycopg2==2.6
pycrypto==2.6.1
pyelasticsearch==1.2.3
python-ldap==2.4.19
pytz==2015.2
redis==2.10.3
requests==2.7.0
simplejson==3.6.5
six==1.9.0
sqlparse==0.1.15
switch2bill-common==2.8.5
urllib3==1.10.4
wsgiref==0.1.2
xmltodict==0.9.2

注意:如果我从我的 virtualenv 中卸载 South,我仍然会遇到同样的错误。

我已尝试从我的项目中解决我能够找到的所有弃用警告。但无论如何,迁移错误仍然存​​在。谁能看到任何可能的解决方案?谢谢:-)

settings.py:

import os
import sys
from json import loads
prod_f = open('/etc/django-settings.json', 'r')
prod_data = prod_f.read()
prod_f.close()
json_data = filter(lambda x: x['id'] == 'mycms', loads(prod_data))[0]

SECRET_KEY = json_data['secretkey']

DATABASES = {
    'default': {
        'ENGINE': json_data['database']['engine'],
        'NAME': json_data['database']['name'],
        'USER': json_data['database']['user'],
        'PASSWORD': json_data['database']['pass'],
        'HOST': json_data['database']['host'],
        'PORT': json_data['database']['port'],
    },
    'backup': {
        'ENGINE': json_data['database']['engine'],
        'NAME': 'tmpcms',
        'USER': json_data['database']['user'],
        'PASSWORD': json_data['database']['pass'],
        'HOST': json_data['database']['host'],
        'PORT': json_data['database']['port'],
    }
}
if 'test' in sys.argv or 'test_coverage' in sys.argv:  # Covers regular testing and django-coverage
    DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
    DATABASES['backup']['ENGINE'] = 'django.db.backends.sqlite3'

# ### DEBUG AND ERROR REPORTING ###
DEBUG = json_data['debug']
ADMINS = json_data['admins']

SEND_BROKEN_LINK_EMAILS = json_data['debug_404']


SERVER_EMAIL = 'no-reply@example.com'
# ### END OF DEBUG AND ERROR REPORTING ###

ALLOWED_HOSTS = json_data['allowed_hosts']
INTERNAL_IPS = json_data['internal_ips']


# django-modeltranslation fallback
MODELTRANSLATION_FALLBACK_LANGUAGES = ('en', 'nb')

gettext = lambda s: s
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))

from django.utils.translation import ugettext_lazy as _

TEMPLATE_DEBUG = DEBUG

MANAGERS = ADMINS

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Oslo'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en'

SITE_ID = 1

USE_I18N = True
USE_L10N = True
USE_TZ = True

MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
STATIC_URL = '/static/'

# URL where the users should be redirected to login.
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
# From #9820: missing link
LOGIN_URL = '/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put absolute paths here, like "/home/html/static" or "C:/www/django/static".
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    # 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.cache.UpdateCacheMiddleware',  # caching
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.doc.XViewMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',  # caching
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.i18n',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'cms.context_processors.cms_settings',
    'sekizai.context_processors.sekizai',
    'ga_tracking.context_processors.ga_tracking_id',
)

from cms import __version__ as cms_version
from djangocms_text_ckeditor import __version__ as cms_cked_v
int_cms_v = map(int, cms_version.split('.')[:1])
int_cms_cked_v = map(int, cms_cked_v.split('.')[:1])
if int_cms_v[0] == 3:
    if int_cms_cked_v[0] == 1:
        raise RuntimeError('It seems that you are running django-cms v3.X. Please upgrade to djangocms_text_ckeditor>=v2')
elif int_cms_cked_v[0] > 1:
    raise RuntimeError('It seems that you are running django-cms v3.X and djangocms_text_ckeditor>=v2. Please downgrade djangocms_text_ckeditor to v1.x.')


ROOT_URLCONF = 'mycms.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'mycms.wsgi.application'

TEMPLATE_DIRS = (
    # Put absolute paths here, like "/home/html/django_templates" or "C:/www/django/templates".
    os.path.join(PROJECT_PATH, "templates"),
)

import re
IGNORABLE_404_URLS = (
    re.compile(r'^/cms_search/'),
    re.compile(r'/favicon.ico'),
    re.compile(r'/'),
)

CMS_TEMPLATES = (
    # a bunch of templates
)

CMS_PERMISSION = True

LANGUAGES = [
    ('nb', _('Norwegian')),
    ('en', _('English')),
]

CMS_LANGUAGES = {
    1: [
        {
            'code': 'en',
            'name': 'English',
            'fallbacks': ['nb'],
            'public': True,
        },
        {
            'code': 'nb',
            'name': 'Norsk',
            'public': True,
        }
    ],
    'default': {
        'fallbacks': ['en', 'nb'],
        'redirect_on_fallback': True,
        'public': False,
        'hide_untranslated': False,
    }
}

MIGRATION_MODULES = {
    'cms': 'cms.migrations_django',
    'menus': 'menus.migrations_django',
}

# South migration unit tests integration: deactivate
# http://south.readthedocs.org/en/latest/unittests.html
SOUTH_TESTS_MIGRATE = False

# ###### django-guardian config #######
AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',  # this is default
    'guardian.backends.ObjectPermissionBackend',  # django-guardian object-specific backend
)

ANONYMOUS_USER_ID = '-1'
# ### END OF django-guardian config ###

ARCHIVE_PAGE_SIZE = 15
DISABLE_LATEST_NEWS_PLUGIN = True

# ###### LDAP CONFIG #######
LDAP_SERVER = 'ldap://ldapproxy1.uib.no'
LDAP_USERNAME = LDAP_PASSWORD = ''
LDAP_BASE_DN = 'dc=uib,dc=no'
# ### END OF LDAP CONFIG ###


# ####### HAYSTACK CONFIG #######
import os
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    }
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
HAYSTACK_CUSTOM_HIGHLIGHTER = 'utils.haystack_utils.StrongUniHighlighter'
# #### END OF HAYSTACK CONFIG ###

# ###### EASY-THUMBNAILS CONFIG #######
THUMBNAIL_ALIASES = {
    '': {
        'avatar_list': {'size': (45, 80), 'crop': 'scale'},
        'avatar_department_list': {'size': (45, 75), 'crop': 'scale'},
        'avatar_detail': {'size': (185, 201), 'crop': 'scale'},
        'avatar_plugin': {'size': (48, 76), 'crop': 'scale'},
        'news_small': {'size': (300, 200), 'crop': 'scale'},
        'news_medium': {'size': (364, 200), 'crop': 'scale'},
        'news_front_medium': {'size': (252, 150), 'crop': 'smart'},
        'news_big': {'size': (535, 354), 'crop': 'scale'},
        'share_linkedin': {'size': (180, 110), 'crop': 'smart'},
        'share_facebook': {'size': (600, 315), 'crop': 'smart'},
        'share_twitter': {'size': (120, 120), 'crop': 'smart'},
    }
}

SOUTH_MIGRATION_MODULES = {
    'easy_thumbnails': 'easy_thumbnails.south_migrations',
}

# The default quality level for JPG images on a scale from 1 (worst) to 95 (best).
# Technically, values up to 100 are allowed, but this is not recommended.
# http://easy-thumbnails.readthedocs.org/en/latest/ref/settings/#easy_thumbnails.conf.Settings.THUMBNAIL_QUALITY
THUMBNAIL_QUALITY = 85

# ### END OF EASY-THUMBNAILS CONFIG ###

# ### PIWIK STUFF, FOR MONITORING ###
PIWIK_SITE_ID = 1
PIWIK_URL = 'http://analytics.bccs.uib.no/'
GOOGLE_ANALYTICS_PROPERTY_ID = json_data['analytics_id']
# ####### END OF PIWIK STUFF ########

# ###### GOOGLE ANALYTICS #######
GA_TRACKING_ID = json_data['analytics_id']
GA_DOMAIN = 'uni.no'
# ### END OF GOOGLE ANALYTICS ###

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',
    'django.contrib.sitemaps',

    'modeltranslation',

    # django-cms
    'djangocms_text_ckeditor',
    'cms',
    'mptt',
    'menus',
    'sekizai',


    # django-cms optional plugins
    'djangocms_file',
    'djangocms_link',
    'djangocms_picture',
    'easy_thumbnails',  # requirement for djangocms_picture
    #'djangocms_text', deactivated because of django-text-ckeditor
    'djangocms_video',
    # django-cms versioning
    'reversion',
    'django_extensions',
    'guardian',
    'country_dialcode',
    'ckeditor',
    'ga_tracking',
    'analytical',
    'cookielaw',

    # django-haystack. Must be before custom apps
    'haystack',

    # custom developed modules
    'mycms',
    'staff',
    'project',
    'department',
    'group',
    'research_area',
    'topics',
    'news',
    'newsarchive',
    'cms_search',
    'manual_uploads',
)
if 'test' in sys.argv or 'test_coverage' in sys.argv:
    INSTALLED_APPS += filter(lambda app: app != 'djangocms_text_ckeditor', INSTALLED_APPS)
if DEBUG:
    INSTALLED_APPS += ('debug_toolbar',)
    DEBUG_TOOLBAR_PATCH_SETTINGS = False
    MIDDLEWARE_CLASSES = (
        'django.middleware.cache.UpdateCacheMiddleware',  # caching
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.locale.LocaleMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.doc.XViewMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
        'cms.middleware.page.CurrentPageMiddleware',
        'cms.middleware.user.CurrentUserMiddleware',
        'cms.middleware.toolbar.ToolbarMiddleware',
        'cms.middleware.language.LanguageCookieMiddleware',
        'debug_toolbar.middleware.DebugToolbarMiddleware',
        'django.middleware.cache.FetchFromCacheMiddleware',  # caching
    )

LOCALE_PATHS = (
    os.path.join(PROJECT_PATH, 'locale'),
)

# for django-ckeditor:
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_UPLOAD_PATH = 'ck_uploads/'
CKEDITOR_CONFIGS = {
    'default': {
        'width': '100%',
        'toolbar': 'full',
        'extraPlugins': 'image2,templates,dialogui,dialog,clipboard,lineutils,widget,oembed',
        'removePlugins': 'iframe,stylescombo,font,colorbutton,colordialog,forms,save,newpage,flash',
        'language_list': ['nb:Bokmål', 'en:English'],
        'templates_replaceContent': False,
    },
    'newsletter': {
        'width': '100%',
        'toolbar': [
            ['Format', 'FontSize', "Bold", "Italic", "Underline", "Strike", "SpellChecker"],
            ['TextColor', 'BGColor'],
            [
                'NumberedList', 'BulletedList', "Indent", "Outdent",
                'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'
            ],
            ['Undo', 'Redo'], ["Source"],
        ],
    },
    'basic': {
        'width': '100%',
        'toolbar': 'Basic',
    }
}
CKEDITOR_IMAGE_BACKEND = 'pillow'
# for djangocms-text-ckeditor:
CKEDITOR_SETTINGS = {
    'language': 'en',
    'toolbar': 'full',
    'skin': 'moono'
}

# FOR django-redis-cache
CACHES = {
    'default': {
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': 'localhost:6379',
        'OPTIONS': {
            'DB': 1,
            # 'PASSWORD': 'yadayada',
            'PARSER_CLASS': 'redis.connection.HiredisParser'
        },
    },
}
# END django-redis-cache

# FOR django caching
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = ''
# END django caching

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console': {
            'level': 'ERROR',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': 'ERROR',
            'propagate': True,
        },
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        'department.models': {
            'handlers': ['console'],
            'level': 'ERROR'
        },
        'django.db.backends': {
            'level': 'ERROR',
            'handlers': ['console'],
        },
    }
}

LOGIN_URL = '/login/'
TEST_RUNNER = 'django.test.runner.DiscoverRunner'

更新:根据 dukeofweatherby 的建议,我从 urls.py 中删除了对 admin.autodiscover() 的调用。无论如何,在这之后我仍然得到同样的错误。

更新 2:from translation import * 在导入 TranslationAdmin 之前解决了问题

正好遇到这个问题,我可以通过删除

来解决它
admin.autodiscover()

Django 1.7 automatically discovers 新应用程序加载功能中的管理文件,我猜这会扰乱加载顺序。

请务必阅读文档并在 django.contrib.admin 之前注册 modeltranslation。这解决了我的问题。

INSTALLED_APPS = (
    ...
    'modeltranslation',
    'django.contrib.admin',
    ....
)

希望对您有所帮助。