#2000: allow generic views to respond with non text/html content types
-----------------------------+----------------------------------------------
 Reporter:  [EMAIL PROTECTED]  |       Owner:  adrian
     Type:  enhancement      |      Status:  new   
 Priority:  normal           |   Milestone:        
Component:  Admin interface  |     Version:        
 Severity:  normal           |    Keywords:        
-----------------------------+----------------------------------------------
 I needed to have a page respond with a text/plain content type.
 here's the patch
 
 {{{
 Index: views/generic/list_detail.py
 ===================================================================
 --- views/generic/list_detail.py        (revision 2970)
 +++ views/generic/list_detail.py        (working copy)
 @@ -6,7 +6,8 @@
 
  def object_list(request, queryset, paginate_by=None, allow_empty=False,
          template_name=None, template_loader=loader,
 -        extra_context={}, context_processors=None,
 template_object_name='object'):
 +        extra_context={}, context_processors=None,
 template_object_name='object',
 +        mimetype=None):
      """
      Generic list of objects.
 
 @@ -73,12 +74,13 @@
          model = queryset.model
          template_name = "%s/%s_list.html" % (model._meta.app_label,
 model._meta.object_name.lower())
      t = template_loader.get_template(template_name)
 -    return HttpResponse(t.render(c))
 +    return HttpResponse(t.render(c), mimetype=mimetype)
 
  def object_detail(request, queryset, object_id=None, slug=None,
          slug_field=None, template_name=None, template_name_field=None,
          template_loader=loader, extra_context={},
 -        context_processors=None, template_object_name='object'):
 +        context_processors=None, template_object_name='object',
 +        mimetype=None):
      """
      Generic list of objects.
 
 @@ -113,6 +115,6 @@
              c[key] = value()
          else:
              c[key] = value
 -    response = HttpResponse(t.render(c))
 +    response = HttpResponse(t.render(c), mimetype=mimetype)
      populate_xheaders(request, response, model, getattr(obj,
 obj._meta.pk.name))
      return response
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2000>
Django <http://code.djangoproject.org/>
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to