错误: [ Errno 18]无效的跨设备链接

我使用的是 django 1.6.5和 python 2.7。 我在我的应用程序中有导入功能,我得到了错误:

OSError: [Errno 18] Invalid cross-device link

我对这部分代码有疑问:

os.rename(db_temp, settings.DATABASES['bookmat']['NAME'])

设置中的代码:

'bookmat': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/my_projects/book/db/bookmat.sqlite3',
},
81869 次浏览

rename only works when the source and target names are on the same file system. You probably have different mounts. Otherwise you get that error. You can implement the same effect with a copy and a delete.

os.rename only works if source and destination are on the same file system. You should use shutil.move instead.