Very cool, Rajesh D. Thanks. Mike
On Jul 11, 12:31 am, Rajesh D <rajesh.dha...@gmail.com> wrote: > On Jul 10, 11:06 am, adelaide_mike <mike.ro...@internode.on.net> > wrote: > > > > > I suspect this is a question more for a PostgreSQL list, but please > > bear with me. > > > In Django 1.0.2 working with PostgreSQL 8.3 I have a model with an > > implied pkey. PostgreSQL syas this: > > > CREATE TABLE wha_property > > ( > > id serial NOT NULL, > > propnum character varying(16) NOT NULL, > > beds integer, > > baths integer, > > rooms integer, > > garage character varying(8), > > frontage integer, > > is_corner boolean, > > street_id integer NOT NULL, > > land_area numeric(10,2), > > year_built integer, > > valuation_nr character varying(16), > > CONSTRAINT wha_property_pkey PRIMARY KEY (id), > > CONSTRAINT wha_property_street_id_fkey FOREIGN KEY (street_id) > > REFERENCES wha_street (id) MATCH SIMPLE > > ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY > > DEFERRED, > > CONSTRAINT wha_property_street_id_key UNIQUE (street_id, propnum) > > > The wha_property table is populated with 500,000 rows from another > > database. There are gaps in the series of used id numbers. > > > If I attempt to insert a new row Django mostly reports an integrity > > violation at wha_property_pkey, though a couple of times with > > different parent rows it has worked. My very newbie view for > > inserting or updating a row is here: > > >http://dpaste.com/65435/ > > > I would be very happy if someone can spot where I have an error. If > > anyone cares to criticise my view, please be gentle. I am new at this > > Django/PostgreSQL magic. > > The sequence for the id column might be out of sync. That would cause > your inserts to pick an id that already exists. > > Try the following command: > > python manage.py sqlsequencereset wha > > That will print out the SQL that you need to run to get your sequences > back in sync with your data. Run that SQL. Then try inserting new data > through your view again. > > -RD --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---