Monday, July 23, 2012

Re: Can't access members in a template

^^ as above ...

try ...

<table>
{% for user in u %}
<tr><td>User ID</td><td>{{user.id}}</td></tr>
<tr><td>User Name</td><td>{{user.name}}</td></

tr>
<tr><td>User E-mail</td><td>{{user.email}}</td></tr>
<tr><td>Date/Time joined</td><td>{{user.date}}</td></tr>

{% end %}
</table>



On Mon, Jul 23, 2012 at 6:50 PM, Dmitry Zimnukhov <zimnuhov@gmail.com> wrote:
Note, that u1 is not a model instance, but a QuerySet object
To get a model you should call manager's "get" method rather than "filter"
replace:
u1 = User.objects.filter(id=u)
with:
u1 = User.objects.get(id=u)

2012/7/23 twelve_o_clock <twelve_o_clock@lavabit.com>:
> I tried that and it still did not work. Also, {{u}} and {{i}} without spaces
> works, but it doesn't work when I try to access the member of something like
> {{ u.name }}.
>
> On Monday, July 23, 2012 9:14:24 AM UTC-7, Kurtis wrote:
>>
>> Try: {{ u.name }} (with spaces)
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/8Xvau8WcTm8J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Regards,
Sithembewena Lloyd Dube

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment