Jacob: Great! I have played it safe with the getattr construct,
figuring that the new object instance _might_ be constructed with an
id attribute set to None prior to save().

On Jul 13, 2:46 pm, "Lic. José M. Rodriguez Bacallao"
<[EMAIL PROTECTED]> wrote:
> thanks, that work more efficient that my way of do it, I was getting the
> user from the database to see if the user exist. I like your solution, is
> pretty clean and simple. Thanks a lot.
>
> On 7/13/07, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 7/13/07, JeffH <[EMAIL PROTECTED]> wrote:
>
> > > if getattr(model_instance, 'id', None) is None:
> > >   model_instance.created_by = whatever
>
> > Also take a look at ``hasattr()``:
> >http://docs.python.org/lib/built-in-funcs.html#l2h-35
>
> > Jacob
>
> --
> 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