Saturday, December 24, 2011

Re: selecting single column from models

Well i have solved the problem now I need to seperate the string:

this is the output:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{'customer_handle': u'srinivask321'} {'customer_handle':
u'sachin_palde'} {'customer_handle': u'BrainsLane'}
{'customer_handle': u'LankeshZ'}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Following is the code in views.py:
-------------------------------------------------------------------------------
x = Customer.objects.all().values('customer_handle')
return render_to_response('xyz.html',{ 'bb':x })
-------------------------------------------------------------------------------

Following is the code in xyz.html
-------------------------------------------------------------------------------
{% for x in bb %}
{{ x }}
{% endfor %}
-------------------------------------------------------------------------------

thanks in advance

On Dec 25, 3:47 am, lankesh87 <lankesh...@gmail.com> wrote:
> I am using sqlite3 as db and in django i want to use values from
> table.
>
> For e.g Customer table has value customer_id, customer_handle,
> token_auth_key,token_sec_key.
>
> my query in views.py is:
>
> --------------------------------------------------------------------------------
> x = Customer.objects.all()
> return render_to_response('xyz.html',{ 'bb':x })
> --------------------------------------------------------------------------------
>
> in xyz.html code is:
>
> --------------------------------------------------------------------------------
> {{ bb }}
> --------------------------------------------------------------------------------
>
> When I try to use value of say token_auth_key I get following
>
> [<Customer: Customer object>, <Customer: Customer object>]
>
> please tell me what am I doing wrong??
>
> I just want to select values for few columns. How to do that??

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate