How to handle values_list?

2013-10-17 Thread Andrew Michael
Hi, I am new to Django and need some help. My issue is on my web page the data is showing up like this: [u'Green'] and I want it to only show Green - without the unicode wrapping. Can you please explain why this is happening and how do I fix it? Here is my code. *models.py:* Class Name(mo

Re: How to handle values_list?

2013-10-17 Thread Bill Freeman
Try: {{ name.0.name }} On Thu, Oct 17, 2013 at 2:30 PM, Andrew Michael wrote: > Hi, > > I am new to Django and need some help. My issue is on my web page the data > is showing up like this: [u'Green'] and I want it to only show Green - > without the unicode wrapping. Can you please explain

Re: How to handle values_list?

2013-10-17 Thread Andrew Michael
Unfortunately, that did not work. When I put that in the template I get nothing for name, not even [u'Green']. Any other thoughts? On Thursday, October 17, 2013 4:19:57 PM UTC-4, ke1g wrote: > > Try: > > {{ name.0.name }} > > > On Thu, Oct 17, 2013 at 2:30 PM, Andrew Michael > > > wrote:

Re: How to handle values_list?

2013-10-17 Thread Daniel Roseman
On Thursday, 17 October 2013 19:30:09 UTC+1, Andrew Michael wrote: > Hi, > > I am new to Django and need some help. My issue is on my web page the data > is showing up like this: [u'Green'] and I want it to only show Green - > without the unicode wrapping. Can you please explain why this is hap

Re: How to handle values_list?

2013-10-17 Thread Charly Román
Have you tried used get instead filter? 2013/10/17 Daniel Roseman : > On Thursday, 17 October 2013 19:30:09 UTC+1, Andrew Michael wrote: >> >> Hi, >> >> I am new to Django and need some help. My issue is on my web page the data >> is showing up like this: [u'Green'] and I want it to only show Gree

Re: How to handle values_list?

2013-10-17 Thread Leonardo Giordani
Andrew, I think that the view is missing something: def enter_name(request): my_number = request.user.number name = Name.objects.filter(pk=my_number).values_list('city', flat=True) *data = {...} * *return render_to_response('template.html', data, context_instance=RequestContext

Re: How to handle values_list?

2013-10-18 Thread Andrew Michael
Thanks to Leonardo, Daniel and Charly this issue is resolved! Each of your comments helped me. I changed my views.py file filter statement: FROM: name = Name.objects.filter(pk=my_**number).values_list('city', flat=True) TO: name = Name.objects.get(pk=number).name And in my template I have the s