dimanche 27 avril 2014

Python 2.7 - impossible de configurer neo4jDjango graphique de base de données : objet n'a aucun attribut « db_type » - Stack Overflow


I'm starting a project and I keep getting this error when executing the


manage.py sql *ApplicationName*

The trace back is as follows:


  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'

The code is pretty much a simple example of the tutorial after many attempts to try to solve the problem.


The setings.py are also supposed to be correct, since they are copied from neo4Django tutorial.


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 server is running, and in the sqllite and also in a mysql database things are working, so the problem must be on the neo4j or neo4django side. Also things work when not using neo4Django models in the domain.


The model is as presented:


from neo4django.db import models

class Person(models.NodeModel):
name = models.StringProperty()
age = models.IntegerProperty()
friends = models.Relationship('self',rel_type='friends_with')



The manage.py sql appname command (copied from the django documentation)



Prints the CREATE TABLE SQL statements for the given app name(s).



So If you are going to use Νeo4j and not MySQL or SQLite, there is no need to get the CREATE TABLE SQL statements. Besides that you probably would like to better run the syncdb command, but once more you are not using a relational db, but Neo4j, so you don't need to run neither.


The only reason you should include a db at the DATABASES declaration on your settings.py is just because, if you don't, an ImproperlyConfigured error will be raised.


So the simple answer is that the error is correct, just don't run any Relational db related django command.


One more tip, don't use the pypi package but the github version https://github.com/scholrly/neo4django (pip install -e git+https://github.com/scholrly/neo4django/#egg=neo4django)



I'm starting a project and I keep getting this error when executing the


manage.py sql *ApplicationName*

The trace back is as follows:


  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'

The code is pretty much a simple example of the tutorial after many attempts to try to solve the problem.


The setings.py are also supposed to be correct, since they are copied from neo4Django tutorial.


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 server is running, and in the sqllite and also in a mysql database things are working, so the problem must be on the neo4j or neo4django side. Also things work when not using neo4Django models in the domain.


The model is as presented:


from neo4django.db import models

class Person(models.NodeModel):
name = models.StringProperty()
age = models.IntegerProperty()
friends = models.Relationship('self',rel_type='friends_with')


The manage.py sql appname command (copied from the django documentation)



Prints the CREATE TABLE SQL statements for the given app name(s).



So If you are going to use Νeo4j and not MySQL or SQLite, there is no need to get the CREATE TABLE SQL statements. Besides that you probably would like to better run the syncdb command, but once more you are not using a relational db, but Neo4j, so you don't need to run neither.


The only reason you should include a db at the DATABASES declaration on your settings.py is just because, if you don't, an ImproperlyConfigured error will be raised.


So the simple answer is that the error is correct, just don't run any Relational db related django command.


One more tip, don't use the pypi package but the github version https://github.com/scholrly/neo4django (pip install -e git+https://github.com/scholrly/neo4django/#egg=neo4django)


Related Posts:

0 commentaires:

Enregistrer un commentaire