Thanks Alex, I didn't know this function, that's what I needed!
Bastien

On Apr 20, 1:40 pm, Alex Koshelev <daeva...@gmail.com> wrote:
> Hi, Bastien.
>
> I think the simple solution with property may be the best aproach if
> you cannot change dependent code:
>
> user = property(lambda self: self.author)
>
>
>
> On Mon, Apr 20, 2009 at 3:37 PM, Bastien <bastien.roche...@gmail.com> wrote:
>
> > You're right Dougal, I *should* do that I have various apps already
> > working with the whole project trying to access object.user in general
> > and I was wondering if there was a clean way to alias author. I'm
> > already using some workarounds but it's dirty...
>
> > On Apr 20, 1:26 pm, Dougal Matthews <douga...@gmail.com> wrote:
> >> why don't you just access entry.author rather than entry.user?
> >> I think perhaps I'm not quite following your question.
>
> >> Dougal
>
> >> ---
> >> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
>
> >> 2009/4/20 Bastien <bastien.roche...@gmail.com>
>
> >> > Hi,
>
> >> > I searched the doc but couldn't find anything about this: I have a
> >> > model for a blog entry that contains a foreign key to user and is
> >> > named author. But that would be really convenient for me if the object
> >> > would respond to the keyword 'user' as well: entry.user doesn't exist
> >> > in the model but I would like it to return what entry.author usually
> >> > returns, just like an alias. Does anything like that exists in Django?
> >> > is it considered good practice? I could just use the author key or
> >> > rename it to user but what happens is that I have various applications
> >> > that already work with either object.user or object.author and I don't
> >> > want to rewrite them all. Thanks.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to