Wednesday, October 31, 2012

getting data from a dictionary in a view

I want to interrogate a dictionary for a particular text

     cursor = connection.cursor()
     cursor.execute("SELECT distinct feature, featuredetails from features where the_id = %s", [id])
     feature = dictfetchall(cursor)

results in
[{'featuredetails': u'', 'feature': u'TV_SET'}, {'featuredetails': u'', 'feature': u'INVERTER'}, {'featuredetails': u'', 'feature': u'HEATING'}]

So I want to know if the key 'feature' contains TV_SET or INVERTER or HEATING

Been trying various things for hours and not got anywhwere so far so any help would be much appreciated

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