Question

I am using Neo4Django in my django based application and trying to use two databases at the sametime : Neo4j and PostGIS. So I configured settings.py as suggested in the docs (http://neo4django.readthedocs.org) and models.py as well.

When I try to run syncdb , I get this message

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)

but when I check if the table and the graph were created, I find nothing!

I am using django 1.4 and neo4j 1.9.M05.

Here is how I declared my databases in 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']

and I declared my models.py like this :

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()

thanks for your help


EDIT

When I run python manage.py sqlall testapp (where testapp is my app and after deleting the neo4j models , otherwise it won't work ), i am getting that sql that permit to create the table :

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;

after that I run ./manage.py syncdb and ONLY the pointsOfInterest table is created (not the graph )

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)

Any ideas why the nodes representing my models are not created in the graphdb?

Was it helpful?

Solution

Actually there wasn't any problem at all !

The first time i ran ./manager.py syncdb the pointsOfInterest table was created in the sql database and i didn't noticed that

For the following attempts, i was expecting this command to insert the neo4j models as a kind of 'root' nodes for the future nodes that will be inserted in the graphdb (while it seems that this command doesn't do this), and focusing on the fact that the previous table weren't added ( whereas it was added before , and Django doesn't replace existing tables )

Problem resolved !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top