Generic views and the User object

0 views
Skip to first unread message

Alice

unread,
Dec 29, 2005, 8:44:44 AM12/29/05
to Django users
I'm trying to access the username of a journal post in a generic
object_detail/list view like this:

{{ object.poster.username }}

however I'm not getting anything whatsoever ... my model is

class Journal(meta.Model):
poster = meta.ForeignKey(User, editable=False)
subject = meta.CharField(maxlength=30)
entry = meta.TextField(blank=True)
...

Is anything the problem or have I missed a caveat somewhere?


Alice

Maniac

unread,
Dec 29, 2005, 8:55:05 AM12/29/05
to django...@googlegroups.com
Alice wrote:

object.poster is not your poster but rather a reference to it (an ID).
To get to real object and to its username you should use Django's get_*
method:

{{ object.get_poster.username }}

Alice

unread,
Dec 29, 2005, 9:01:53 AM12/29/05
to Django users
works like a charm, thanks.

Alice

Reply all
Reply to author
Forward
0 new messages