Currently there is no way to pass the Content-Type header field while using render_to_response(). This means dropping down to using template_loader() and HttpResponse objects to handle this fairly trivial task.
A simple change to render_to_response() would allow the developer to pass that information along:
def render_to_response(*args, **kwargs):
ctype = kwargs.pop('content_type', None)
return HttpResponse(loader.render_to_string(*args, **kwargs), mimetype=c
type)
load_and_render = render_to_response # For backwards compatibility.
To use it, simply do:
return render_to_response( 'imageview/gallery', content_dictionary,
content_type = "application/xhtml+xml; charset=%s" % DEFAULT_CHARSET,
context_instance = DjangoContext(request) )