Yes, that would be the relationship and that was actually the first
thing I tried. The template gets passed an "array" of "entry" objects.
Within the template, I loop through them printing the headline, portion
of the body, and the created date. With Author's as a foreign key, I
assumed you could do something like {{ entry.author.name }} but I get
nothing in my output when I do this. I assume that objects passed in a
template can't follow their foreign key relationships.

Sorry, I am still very new to both Django as well as Python. Forgive me
if I am not stating my problem clearly.


Ivan Sagalaev wrote:
> mediumgrade ÐÉÛÅÔ:
> > I have a simple blog app that I am working on. In this app, I have
> > ojects for  each entry as well as the author who wrote it. I wrote a
> > simple view which displays a list of all entrys made, but I want that
> > list to include the name of the author. Since the author's name is not
> > part of the entry, how do I access attributes from related objects
> > within a template?
>
> If I'm guessing correctly that relation is like this:
>
>      class Article(models.Model):
>        author = models.ForeignKey(Author)
> 
> ... then {{ article.author.name }} should work.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to