I had wanted to make up a unique field combining some other field and,
ideally, an autoincrementing number unique to this class...  I'd love
to make this the primarykey, but I can't make up a SlugField as the
primary key and another field to be the autoincrementing number
because AutoField is only valid for the primary key.

So I decided to make up a SlugField as just a unique field (with "id"
as normal) and then I planned to populate the slug myself from
some-other field AND "id" in the _pre_save routine.  (since it seemed
that prepopulate happened only in the admin interface and I needed it
to happen all the time)

Although the docs say that _pre_save "is called just before an object
is saved to the database", that's not quite correct.  _pre_save is
called long before the db is committed, and BEFORE the AutoField "id"
is set meaning that when _pre_save runs, id is null.

So this leads me to several questions:

Why not allow any integer fields to be autoincrementing (oops, that
may be basic sql ... I haven't checked)?

How else can I get a field to be a class-unique autoincrementing value?

Why have _pre_save hook in before the autoincrementing fields get
computed?  Shouldn't _pre_save happen after the auto fields are set so
that you can write code to USE the computed "id"?

Thanks

-- 
Glenn

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to