this works for me:

if getattr(model_instance, 'id', None) is None:
  model_instance.created_by = whatever

On Jul 13, 1:28 pm, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> Hi, I got a little problem. I need to store in a model the first user who
> created it (created_by) and the user who last modified it
> (last_modified_by). So, with the second one, there is no problem, every time
> a user save the object, the pre_save signal is dispatched and I catch it so
> I can set the "last_modified_by" field to current user but, right there, I
> need to set the "created_by" field and I don't know how to do it, my
> algorithm is pretty simple:
>
> if model_instance.created_by is not set:
>     set model_instance.created_by to current user
> .
> .
> .
> continues with save
>
> the problem here is how to know if model_instance.created_by field is set or
> not, I think that it can be known if a can figure out if save method  is
> going to insert or update, but, how  I know it?
>
> --
> Lic. José M. Rodriguez Bacallao
> Cupet
> -----------------------------------------------------------------
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
> mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic por
> profesionales
> -----------------------------------------------------------------


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to