Re: Can't access members in a template

2012-07-23 Thread twelve_o_clock
That worked. Thanks for the help.

On Monday, July 23, 2012 9:50:07 AM UTC-7, Dmitry Zimnukhov 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) 
>
>

-- 
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/-/6Jd96LIUZ48J.
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.



Re: Can't access members in a template

2012-07-23 Thread Sithembewena Lloyd Dube
pardon, the closing 'for' tag would be {% endfor %}

On Mon, Jul 23, 2012 at 6:53 PM, Sithembewena Lloyd Dube
wrote:

> ^^ as above ...
>
> try ...
>
> 
> {% for user in u %}
> User ID{{user.id }}
> User Name{{user.name }}
> tr>
> User E-mail{{user.email}}
> Date/Time joined{{user.date}}
>
> {% end %}
> 
>
>
> On Mon, Jul 23, 2012 at 6:50 PM, Dmitry Zimnukhov 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 :
>> > 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+unsubscr...@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+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
>



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



Re: Can't access members in a template

2012-07-23 Thread Sithembewena Lloyd Dube
^^ as above ...

try ...


{% for user in u %}
User ID{{user.id }}
User Name{{user.name }}
User E-mail{{user.email}}
Date/Time joined{{user.date}}

{% end %}



On Mon, Jul 23, 2012 at 6:50 PM, Dmitry Zimnukhov 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 :
> > 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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't access members in a template

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



Re: Can't access members in a template

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



Re: Can't access members in a template

2012-07-23 Thread Kurtis Mullins
Try: {{ u.name }} (with spaces)

On Mon, Jul 23, 2012 at 10:35 AM, twelve_o_clock  wrote:

> I am trying to access data in a template in django. I have a variable u
> with members name, email, id, and date. However when I put {{u.name}} in
> a template, it doesn't appear in the HTML file even though just {{u}}
> appears just fine.
>
> For reference, here is the template:
>
> 
> 
> 
> View user {{ u.id }}
> 
> 
> 
> 
> User ID{{u.id}}
> User Name{{u.name}}
> User E-mail{{u.email}}
> Date/Time joined{{u.date}}
> 
> {{u}}
> {{i}}
> {{u.name}}
> 
> 
>
> and here is the function in views.py
>
> def user(request, u):
> u1 = User.objects.filter(id=u)
> return render_to_response('micropost/user.html', {'u':u1, 'i':u})
>
> --
> 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/-/FyEy3rIU1LkJ.
> 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.
>

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



Can't access members in a template

2012-07-23 Thread twelve_o_clock


I am trying to access data in a template in django. I have a variable u 
with members name, email, id, and date. However when I put {{u.name}} in a 
template, it doesn't appear in the HTML file even though just {{u}} appears 
just fine.

For reference, here is the template:




View user {{ u.id }}




User ID{{u.id}}
User Name{{u.name}}
User E-mail{{u.email}}
Date/Time joined{{u.date}}

{{u}}
{{i}}
{{u.name}}



and here is the function in views.py

def user(request, u):
u1 = User.objects.filter(id=u)
return render_to_response('micropost/user.html', {'u':u1, 'i':u})

-- 
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/-/FyEy3rIU1LkJ.
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.