> > from django.db import models >> >> # Create your models here. >> class Cardrange(models.Model): >> minbin = models.DecimalField(max_digits=12, decimal_places=0) >> maxbin = models.DecimalField(max_digits=12, decimal_places=0) >> >> minpan = models.IntegerField() >> maxpan = models.IntegerField() >> >> ... more fields and 'def __unicode__() ... >> >> > Are you absolutely sure there is not: > > id = models.IntegerField(primary_key=True) > > among the "more fields" >
Karen Hi, There's no 'id' in my other fields; the manage.py sql DOES report it as being 'serial', however the field definition in pgadmin III reports: -- Column: id -- ALTER TABLE cardtype_cardrange DROP COLUMN id; ALTER TABLE cardtype_cardrange ADD COLUMN id *integer*; ALTER TABLE cardtype_cardrange ALTER COLUMN id SET STORAGE PLAIN; ALTER TABLE cardtype_cardrange ALTER COLUMN id SET NOT NULL; ALTER TABLE cardtype_cardrange ALTER COLUMN id SET DEFAULT nextval('cardtype_cardrange_id_seq'::regclass); but the table creation code has it as serial: CREATE TABLE tablename ( id serial NOT NULL, minbin numeric(12) NOT NULL, maxbin numeric(12) NOT NULL, minpan integer NOT NULL, maxpan integer NOT NULL, The actual characteristics of the field from pgadmin ||| include: Name: id Data type: *integer* Default: nextval(<the sequence's name >) Sequence: <the sequence name - which is tablename_id_seq > Primary key yes not NULL yes ... So, it has a sequence, but the sequence is out-of-sync (value=7) with the actual DB (max id is 92,000+), thus the code to first setval() the sequence. Anyway the code seems to work, but it's still odd that the type isn't serial. Ken -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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=.