我用的是django1.10,python3.4。当第一次尝试使用迁移时(项目是django1.6 python2.7),我得到以下错误:
(venv) ruben@erd959:~/Projects/prot-zboss/zboss$ python manage.py makemigrations utils
Traceback (most recent call last):
File "manage.py", line 8, in <module>
execute_from_command_line(sys.argv)
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 106, in handle
loader.check_consistent_history(connection)
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/db/migrations/loader.py", line 276, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/home/nfs/ruben/Projects/prot-zboss/venv/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
AttributeError: 'DatabaseWrapper' object has no attribute 'introspection'
看起来数据库有问题。好吧,似乎如果我删除数据库路由器,它会再次工作,但我需要有我的LDAP功能。在
^{pr2}$这是“的代码”ldapdb.router.router“:
def is_ldap_model(model):
# FIXME: there is probably a better check than testing 'base_dn'
return hasattr(model, 'base_dn')
class Router(object):
"""
A router to point database operations on LDAP models to the LDAP
database.
NOTE: if you have more than one LDAP database, you will need to
write your own router.
"""
def __init__(self):
"Find the name of the LDAP database"
from django.conf import settings
self.ldap_alias = None
for alias, settings_dict in settings.DATABASES.items():
if settings_dict['ENGINE'] == 'ldapdb.backends.ldap':
self.ldap_alias = alias
break
def allow_migrate(self, db, app_label, model_name=None, **hints):
if 'model' in hints and is_ldap_model(hints['model']):
return False
return None
def db_for_read(self, model, **hints):
"Point all operations on LDAP models to the LDAP database"
if is_ldap_model(model):
return self.ldap_alias
return None
def db_for_write(self, model, **hints):
"Point all operations on LDAP models to the LDAP database"
if is_ldap_model(model):
return self.ldap_alias
return None
目前没有回答
相关问题 更多 >
编程相关推荐