#1504: Allow render_to_response() to take a content-type param
------------------------------------+---------------------------------------
   Reporter:  [EMAIL PROTECTED]  |                Owner:  nobody                
     Status:  reopened              |            Component:  Template system    
   
    Version:  SVN                   |           Resolution:                     
   
   Keywords:                        |                Stage:  Design decision 
needed
  Has_patch:  1                     |           Needs_docs:  0                  
   
Needs_tests:  0                     |   Needs_better_patch:  0                  
   
------------------------------------+---------------------------------------
Comment (by Rob van der Linde):

 I tried the first attached diff by James Wheare, but it didn't work for
 me, his method started like:
 
 {{{
 def render_to_response(mimetype=None, *args, **kwargs):
 }}}
 
 However, trying to call that method as follows:
 
 {{{
 def index(request):
         return render_to_response("myapp/index.html", {"foo": "bar"},
 mimetype="application/xhtml+xml")
 }}}
 
 Results in the following error:
 
 non keyword arg after keyword arg
 
 I tried both adjusting the way I call his method, and the order of his
 methods parameters itself, in hope I could get it working, but no luck, I
 kept getting the same error.
 
 So I fixed the bug myself and created a .diff file. I have throughly
 tested this and it works for all these cases:
 
 {{{
 def index(request):
         return render_to_response("myapp/index.html", {"foo": "bar"},
 mimetype="application/xhtml+xml")
 }}}
 
 {{{
 def index(request):
         return render_to_response("myapp/index.html", {"foo": "bar"})
 }}}
 
 {{{
 def index(request):
         return render_to_response("myapp/index.html",
 mimetype="application/xhtml+xml")
 }}}
 
 {{{
 def index(request):
         return render_to_response("myapp/index.html")
 }}}
 
 I used mimetype as the parameter name, since that was the same naming
 convention as in HttpResponse, but if anyone wants to change it to
 content_type instead, that's fine.
 
 I hope this can be included soon, and this longstanding feature resolved.
 Many people would benefit from this, not only is it useful for serving
 XHTML files, but also RSS, XUL, and other XML based formats.
 
 I will attach the .diff file.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/1504#comment:9>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to