我正在启动一个项目,并且在执行时不断收到此错误
manage.py sql *ApplicationName*
回溯如下:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 304, in handle
app_output = self.handle_app(app, **options)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/sql.py", line 19, in handle_app
return u'\n'.join(sql_create(app, self.style, connections[options.get('database')])).encode('utf-8')
File "/usr/lib/python2.7/site-packages/django/core/management/sql.py", line 31, in sql_create
output, references = connection.creation.sql_create_model(model, style, known_models)
File "/usr/lib/python2.7/site-packages/django/db/backends/creation.py", line 44, in sql_create_model
col_type = f.db_type(connection=self.connection)
File "/usr/lib/python2.7/site-packages/neo4django/utils.py", line 161, in __getattr__
return getattr(super(AttrRouter, self), name)
AttributeError: 'super' object has no attribute 'db_type'
经过多次尝试解决问题后,该代码几乎是本教程的一个简单示例。
settings.py 也应该是正确的,因为它们是从 neo4Django 教程中复制的。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'Database.db',
}
}
NEO4J_DATABASES = {
'default' : {
'HOST':'localhost',
'PORT':7474,
'ENDPOINT':'/db/data'
}
}
DATABASE_ROUTERS = ['neo4django.utils.Neo4djangoIntegrationRouter']
Neo4j 服务器正在运行,并且在 sqllite 和 mysql 数据库中一切正常,所以问题一定出在 neo4j 或 neo4django 方面。当不在域中使用 neo4Django 模型时,事情也会起作用。
该模型如下所示:
from neo4django.db import models
class Person(models.NodeModel):
name = models.StringProperty()
age = models.IntegerProperty()
friends = models.Relationship('self',rel_type='friends_with')