在我的开发MacOS上,我有几个django项目。当我为所有这些(除了一个)运行python manage.py migrate
时,它工作正常。但只在一个项目中它返回此错误:
Running migrations for main:
- Nothing to migrate.
- Loading initial data for main.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/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 "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/lib/python2.7/site-packages/south/migration/__init__.py", line 233, in migrate_app
migrator.load_initial_data(target, db=database)
File "/usr/local/lib/python2.7/site-packages/south/migration/migrators.py", line 224, in load_initial_data
self.post_1_6(target, db)
File "/usr/local/lib/python2.7/site-packages/south/migration/migrators.py", line 242, in post_1_6
old_cache = django.db.models.loading.cache
AttributeError: 'module' object has no attribute 'loading'
同一个项目在生产服务器上迁移良好。你有什么想法吗?
这是pip freeze
输出:
Babel==1.3
BeautifulSoup==3.2.1
Django==1.6.5
Django-Select2==4.2.2
Fabric==1.8.2
MySQL-python==1.2.5
Pillow==2.5.1
South==1.0
Unidecode==0.04.14
aldryn-blog==0.3.12
aldryn-common==0.0.3
argparse==1.2.1
args==0.1.0
bleach==1.4
cmsplugin-filer==0.9.5
cssselect==0.9.1
dj-database-url==0.3.0
django-allauth==0.16.1
django-appconf==0.6
django-classy-tags==0.5.1
django-cms==3.0.2
django-compressor==1.3
django-cumulus==1.0.12
django-debug-toolbar==1.0.1
django-filer==0.9.5
django-grappelli==2.5.1
django-html-sanitizer==0.1.4
django-model-utils==2.0.1
django-mptt==0.6.0
django-polymorphic==0.5.3
django-reversion==1.8.0
django-sekizai==0.7
django-social-auth==0.7.28
django-suit==0.2.5
django-suit-ckeditor==0.0.2
django-suit-redactor==0.0.2
django-taggit==0.11.2
django-tinymce==1.5.2
django-widget-tweaks==1.3
djangocms-admin-style==0.2.2
djangocms-column==1.3
djangocms-file==0.0.1
djangocms-flash==0.0.2
djangocms-googlemap==0.0.5
djangocms-inherit==0.0.1
djangocms-installer==0.5.2
djangocms-link==1.3.4
djangocms-picture==0.0.2
djangocms-style==1.3
djangocms-teaser==0.0.1
djangocms-text-ckeditor==2.1.4
djangocms-video==0.0.1
easy-thumbnails==2.0.1
ecdsa==0.10
gunicorn==19.0.0
html5lib==0.999
httplib2==0.8
iso8601==0.1.10
keyring==3.6
lxml==3.3.1
mock==1.0.1
oauth2==1.5.211
oauthlib==0.6.1
os-diskconfig-python-novaclient-ext==0.1.2
os-networksv2-python-novaclient-ext==0.21
os-virtual-interfacesv2-python-novaclient-ext==0.15
paramiko==1.12.2
pbr==0.7.0
prettytable==0.7.2
progressbar==2.2
pycrypto==2.6.1
pymongo==2.6.3
pymorphy==0.5.6
pyrax==1.6.3
python-memcached==1.53
python-novaclient==2.17.0
python-oauth2==0.5.0
python-openid==2.2.5
python-social-auth==0.1.22
python-swiftclient==2.0.3
pytils==0.3
pytz==2014.1
rackspace-auth-openstack==1.3
rackspace-novaclient==1.4
raven==4.0.4
rax-default-network-flags-python-novaclient-ext==0.2.3
rax-scheduled-images-python-novaclient-ext==0.2.1
requests==2.2.1
requests-oauthlib==0.4.0
retrying==1.2.1
simplejson==3.3.3
six==1.6.1
sqlparse==0.1.11
vboxapi==1.0
wsgiref==0.1.2
yandex-maps==0.7
我尝试重新安装django并升级为南,但结果是一样的。
答案 0 :(得分:2)
确认您已完成以下操作:
./manage.py schemamigration appname --initial
./manage.py migrate appname --fake
稍后进行更改
./manage.py schemamigration appname --auto
./manage.py migrate appname
如果第二个代码块不起作用,您可能需要删除south_migrationhistory
。首先,删除应用文件夹中的migrations
文件夹。然后(安装了SQL):
./manage.py dbshell
SELECT * FROM sqlite_master WHERE type="table";
DROP TABLE south_migrationhistory;
.exit
现在做我上面提到的例程( - 初始, - 假)。