On 5/11/07, Bob Dively <[EMAIL PROTECTED]> wrote: > > On May 10, 5:12 pm, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > > You have to change it to: > > > > Foo_ID = models.AutoField(primary_key=True, editable=False) > > Ah, ok, so even though the db (MySQL) is taking care of incrementing > the column value on insert, the model has to know that the DB is doing > it?
Not quite. AutoField defines a field that tells the DB to choose the next available value. An AutoField is added automatically to every Django model that doesn't define its own 'primary_key=True' field (i.e., you don't need to manually define a primary key on your models unless you want to do something special). IntegerField is just a standard integer. It _can_ be set as a primary key, which enforces the predictable uniqueness, etc constraints, and overrides the creation of the default AutoField primary key. However, if you use IntegerField for your primary key, neither Django nor your DB backend will populate the value. You will need to provide an integer value for every object you save. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

