If I do:
> class Image(Model):
> serial = AutoField()
I get an error when I do syncdb or schemamigration:
> AssertionError: AutoFields must have primary_key=True.
Is this a bug?
---
Roy Smith
r...@panix.com
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Gerald Klein DBA
Linux registered user #548580
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Unlikely considering the assertion was specifically added to AutoField as part of a commit noting:
> Refactored the way save() works so that non-integer primary keys are
> now possible. custom_pk unit tests (from [458]) now pass. Refs #81.
There doesn't seem to be any more information than that, but a quick
search on the tracker[0] many databases seem to have… issues with
non-key autofields (let alone multiple autofields in a single table)
So the solution would be to either use a sequences-using DB backend (aka
not MySQL unless you want to hack that horribly via a dedicated table
with an autoinc PK) and create your own sequence field (which may or may
not be easy, I don't know how complex the SQL underpinnings of a Django
model field can be), or to just do it "by hand" in your model's
overridden save.