python - How do I return a urllib2 response object from within a Django view? -
i know can use shortcuts module make easier see if manually tried create , return response object myself not work:
import urllib2 def djangoview(request): data = '<byte string>' open('body.txt', 'wb').write(data) headers = {'content-type' : 'something', 'accept' : 'somethingelse'} newresponse = urllib2.request('file:body.txt', none, headers) return httpresponse(newresponse)
i don't understand trying do. it's contract of view returns instance of django.http.httpresponse - not allowed return else. doing not shortcut, it's necessity.
Comments
Post a Comment