def BeersAll(request):
print request.COOKIES
attrib_list = dir(request)
print attrib_list
xyz = 'request.'+str(attrib_list[0])
print xyz
beers = Beer.objects.all().order_by('name')
context = {'beers': beers}
return render_to_response('index.html', context, context_instance=RequestContext(request))
output:
{'csrftoken': 'oXhz3P8qcAfTfz0f6KjU9QivGi4wReNe', 'sessionid': 'bwavmmrlquwusixnrvp6hjzbzy2pdly5'}
['COOKIES', 'FILES', 'GET', 'META', 'POST', 'REQUEST', ....]
request.COOKIES
I am trying to loop through the attrib_list and execute all items (ie) request.items)
I am looking for the kind of output i got for request.COOKIES in first line for all other attributes, is there any way to accomplish this in python.
req_data = {'request': []}
for attr in attrib_list:
req_data['request'].append(attr)
and render it to templates. but I dont understand why you would need this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.