我在基于 django 的应用程序中使用 Neo4Django,并尝试同时使用两个数据库:Neo4j 和 PostGIS。所以我按照文档(http://neo4django.readthedocs.org)和models.py 中的建议配置了settings.py。
当我尝试运行 syncdb 时,我收到此消息
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'postgres'):
E-mail address: postgres@gmail.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
但是当我检查表格和图表是否已创建时,我什么也没找到!
我正在使用 django 1.4 和 neo4j 1.9.M05。
以下是我在 settings.py 中声明我的数据库的方式:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango',
'USER': 'postgres',
}
}
NEO4J_DATABASES = {
'default' : {
'HOST':'127.0.0.1',
'PORT':7474,
'ENDPOINT':'/db/data/'
}
}
DATABASE_ROUTERS = ['neo4django.utils.Neo4djangoIntegrationRouter']
我像这样声明了我的models.py:
from neo4django.db import models
from django.contrib.gis.db import models as gis
class Airport(models.NodeModel):
name = models.StringProperty()
iata = models.StringProperty()
icao= models.StringProperty()
city = models.Relationship('self',rel_type='isAT')
#geographical database for storing entities coordinates
class pointsOfInterest(gis.Model):
nodeid = gis.IntegerField()
longitude = gis.FloatField()
latitude = gis.FloatField()
# GeoDjango-specific: a geometry field (MultiPolygonField), and
# overriding the default manager with a GeoManager instance.
objects = gis.GeoManager()
感谢您的帮助
编辑
当我运行python manage.py sqlall testapp
(其中 testapp 是我的应用程序并且在删除 neo4j 模型之后,否则它将无法工作)时,我得到了允许创建表的 sql:
BEGIN;
CREATE TABLE "testapp_pointsofinterest" (
"id" serial NOT NULL PRIMARY KEY,
"nodeid" integer NOT NULL,
"longitude" double precision NOT NULL,
"latitude" double precision NOT NULL
)
;
COMMIT;
之后我运行./manage.py syncdb
并且只创建了 pointsOfInterest 表(不是图表)
postgres@anas-desktop:/home/anas/Desktop/testNeo4Django$ ./manage.py syncdb
Creating tables ...
Creating table testapp_pointsofinterest
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
为什么没有在graphdb中创建代表我的模型的节点的任何想法?