2

プロジェクトを開始していますが、実行時にこのエラーが発生し続けます

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')
4

1 に答える 1

2

manage.py sql appnameコマンド( django ドキュメントからコピー)

指定されたアプリ名の CREATE TABLE SQL ステートメントを出力します。

したがって、 orではΝeo4jなく andを使用する場合は、CREATE TABLE SQL ステートメントを取得する必要はありません。それに加えて、おそらくコマンドをより適切に実行したいと思うでしょうが、もう一度リレーショナル データベースを使用していないため、どちらも実行する必要はありません。MySQLSQLitesyncdbNeo4j

DATABASES宣言にdb を含める必要がある唯一の理由はsettings.py、そうしないとImproperlyConfiguredエラーが発生するからです。

したがって、簡単な答えは、エラーが正しいということです。リレーショナル データベース関連の django コマンドを実行しないでください。

もう 1 つのヒントとして、pypi パッケージではなく github バージョンを使用してください https://github.com/scholrly/neo4django ( pip install -e git+https://github.com/scholrly/neo4django/#egg=neo4django)

于 2013-11-01T12:04:17.593 に答える