Thank you Eric, it helped a lot. The 'name' attribute does get me
confused every now and then...good point!

- nick

On Jan 23, 12:09 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> > Question: In python, how do I access name attribute in Author? That
> > is, I'd like to know how to find out author of each entry.?
>
> Hi Nick,
>
> The relevant documentation is 
> here:http://www.djangoproject.com/documentation/db-api/#related-objects
>
> Basically, since entries have a many-to-many relationship to authors,
> you'll be able to access those authors via 'entry.author_set.all()',
> where entry is any given Entry. For each resulting author, you can get
> its related user as author.name. It can make for some awkward python
> in the views, since author_set returns a list (even if there's only
> one), and if you want to do anything with the authors you need to
> iterate over the list or slice it or something else.
>
> Worth noting: 'name' is a confusing designation for a related field.
> You'd expect 'name' to return a string value, not be a foreign key.
> It's a small issue, but fixing it will make coding easier down the
> line.
>
> Hope that helps,
> Eric
--~--~---------~--~----~------------~-------~--~----~
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