You are welcome!
Setting the Content-Type header works a little different in Django.
You can either specify it when you construct a HttpResponse object ourself:
from django.http import HttpResponse
def myview(request):
response = HttpResponse(content_type="text/xml")
return response
When using the render_to_response shortcut, you cannot use the
content_type-keyword, you have to use mimetype instead (don't know why
exactly, the Django docs say that content_type is only an alias for
mimetype).
render_to_response("template.html", {"ip_address": ip_address},
mimetype="text/xml")
You can also set the content_type header later, however, this looks a
bit cryptic:
from django.shortcuts import render_to_response
def myview(request):
ip_address = request.META['REMOTE_ADDR']
response = render_to_response("template.html", {"ip_address": ip_address})
response._headers['content-type'] = ('Content-Type', 'text/xml')
return response
As you see, the Django people seem to want you rather using the constructor! ;)
Jesaja
On Fri, Jan 30, 2009 at 4:46 PM, arnie <[email protected]> wrote:
>
> Thanks a lot for your detailed reply
> Earlier I have created a class that implements webapp.RequestHandler
> for handling the GET request. The def get(self) is returning a simple
> xml as a response. There I have set the content type as
> self.response.headers['Content-Type'] = 'text/xml' and subsequntly
> generated the xml. Will this xml generating code will work on django
> web app or I need to change it?
> I will also look at the django sample suggested by you
> Thanks once again
> arnie
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---