On 4/18/06, Mathieu Blondel <[EMAIL PROTECTED]> wrote:
> When one saves an object with the save() method, a common need is to
> get the id corresponding to the row that has just been inserted.
>
> p = polls.Poll(...)
> p.save()
> p.id # is set to None
>
> So here are two  possible solutions,
> 1) Either update the primary key columns from a row when save() is
> called
> 2) Or implement a reload() method which would update the whole object
> variables

Hi Mathieu,

Django currently does exactly what you described in "1" -- when you
call save() for the first time, the primary key attribute of the
object is updated with the ID of the newly-saved record. This assumes
that field is defined as an AutoField in the model.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to