Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Lucian Nicolescu
If you are absolutely sure the field is filled in (the sequence is defined) I guess you can allow it to be null in the model definition. On Tue, May 10, 2011 at 7:33 PM, wilbur wrote: > Using exclude works to eliminate this sample_id field from the form, > but I get a > > 'Null

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Amanjeev Sethi
> > Will south add in the new ID field? I have never come across a situation where South was not able to change something in a table for me, so far. Try it please. On Tue, May 10, 2011 at 1:52 PM, wilbur wrote: > I definitely need to keep the database, and have South installed,

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread wilbur
I definitely need to keep the database, and have South installed, but should I get rid of the original primary key and the sequence it depends on? Will south add in the new ID field? On May 10, 11:48 am, Shawn Milochik wrote: > If you don't mind losing all your data you can

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
If you don't mind losing all your data you can destroy the database then do syncdb. If you re-run syncdb without re-creating the database then it will do nothing for existing tables. You can use South[1] if you need to keep your data intact. [1] http://south.aeracode.org/ -- You received

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread wilbur
I will try just removing it from the model. Does this mean I should remove the sample_id variable from the Postgres database as well. Will running syncdb create the new id field for that table? On May 10, 10:33 am, wilbur wrote: > Using exclude works to eliminate this sample_id

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
I think the problem is that you used IntegerField instead of AutoField. http://docs.djangoproject.com/en/1.3/ref/models/fields/#autofield However, why even bother? Why not get rid of that field and use the built-in id field that you're going to get from a Django model? There's no benefit at

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread wilbur
Thanks for helping on this Shawn... My model definition looks like this: class Sample(models.Model): met_type = models.ForeignKey(MetType, verbose_name='Meteorite Type') sample_name = models.CharField(max_length=100, verbose_name='Sample Name') sample_id =

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
What's your model look like? Did you add the foreign_key = True kwarg to the field in question? -- 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,

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread wilbur
Using exclude works to eliminate this sample_id field from the form, but I get a 'Null value in column "sample_id" violates not-null constraint' If one inserts a record directly through Postgresql command line, the sample_id field gets incremented automatically with its sequence, but it does not

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.3/ref/contrib/admin/ Check out 'fields' and 'exclude.' -- 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

How to deal with an auto-incrementing primary key

2011-05-10 Thread wilbur
I am using Django 1.2.4 with a Postgresql 8.4 backend. Before creating my models in Django, I began with a existing Postgresql database with tables for which I had defined integer primary keys that used an autoincrementing sequence on table inserts. When I created my Django models, I defined the