>> >> class User(models.Model): >> user_id = >> models.AutoField(primary_key=True) >> >> This produces a table in sqlite that will NOT take NULL for a value >> when inserting records. You get an error back. > > That's correct behaviour. A primary key column must be unique and not > null. By definition. No bug there.
Right. I stated it because if you do an insert and just leave the autoincrementing field out of the field-list, sqlite will return the "sorry, null is not an acceptable value for this field". I was a bit unclear. > > That's not the right solution. You're making the symptom go away, not > fixing the problem itself. > > Your observation is correct: the SQLite backend doesn't add > AUTOINCREMENT. The fix is to make it always add AUTOINCREMENT. An > AutoField is an auto-increment field: it's not optional. You're right. > > > Shows how infrequently AutoField's are really used in practice. > They're > generally just not that useful to specify. What else do people use for specifying autoinc fields? > > > Anyway, if you you'd like to fix your patch to always do this for the > SQLite backend, that would be great (it looks like a one-line patch to > django/db/backends/sqlite/creation.py). Ok, will do! Thanks Alec --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---