You are right ! It looks that the table has been created the first time and i didn't saw the message.
Concerning the nodeid, i thought that it would be generated automatically and incremented for each new created instance , isn't it ? Thanks for the reply On Thursday, May 30, 2013 3:35:36 PM UTC+2, Tom Evans wrote: > > On Thu, May 30, 2013 at 1:46 PM, Anas <[email protected] <javascript:>> > wrote: > > I am having 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 am getting 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: [email protected] <javascript:> > > 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() > > > > > > 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; > > > > Then i try to create an instance of this table in the `python manage.py > > shell` i am getting this : > > > > > > postgres@anas-desktop:/home/anas/Desktop/testNeo4Django$ ./manage.py > > shell > > Python 2.6.5 (r265:79063, Oct 1 2012, 22:07:21) > > [GCC 4.4.3] on linux2 > > Type "help", "copyright", "credits" or "license" for more > information. > > (InteractiveConsole) > > >>> from testNeo4Django.testapp.models import pointsOfInterest > > >>> > > >>> poi= pointsOfInterest.objects.create() > > Traceback (most recent call last): > > File "<console>", line 1, in <module> > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", > line > > 137, in create > > return self.get_query_set().create(**kwargs) > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line > > 377, in create > > obj.save(force_insert=True, using=self.db) > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py", line > 463, > > in save > > self.save_base(using=using, force_insert=force_insert, > > force_update=force_update) > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py", line > 551, > > in save_base > > result = manager._insert([self], fields=fields, > return_id=update_pk, > > using=using, raw=raw) > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", > line > > 203, in _insert > > return insert_query(self.model, objs, fields, **kwargs) > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line > > 1593, in insert_query > > return query.get_compiler(using=using).execute_sql(return_id) > > File > > > "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", > > line 912, in execute_sql > > cursor.execute(sql, params) > > File > > "/usr/local/lib/python2.6/dist-packages/django/db/backends/util.py", > line > > 40, in execute > > return self.cursor.execute(sql, params) > > File > > > "/usr/local/lib/python2.6/dist-packages/django/db/backends/postgresql_psycopg2/base.py", > > > > line 52, in execute > > return self.cursor.execute(query, args) > > IntegrityError: null value in column "nodeid" violates not-null > > constraint > > > > Any ideas about this ? > > > > thanks for your help > > > > syncdb does not create tables that already exist in the database. It > also doesn't alter tables that exist if you change your models.py. > > Your error traceback clearly indicates that the table exists. The > error says that the field nodeid cannot be null, as specified in your > models.py, but you have (by not passing any values) submitted > nodeid=None. > > Cheers > > Tom > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.

