title: django-rest-framework: Rendering both HTML and JSON with the same ModelViewSet
body: <p>I'm using <code>Django==1.10.5</code> and <code>djangorestframework==3.5.3</code>.</p>
  
  <p>I have a few <code>ModelViewSet</code>s that handle JSON API requests properly. Now, I'd like to use <code>TemplateRenderer</code> to add HTML rendering to those same <code>ModelViewSet</code>s. I started with the <code>list</code> endpoint, and created a simple template that lists the available objects. I implemented the <code>get_template_names</code> to return the template I created.</p>
  
  <p>Accessing that endpoint through the browser works fine when there are <strong>no</strong> objects to list, so everything related to setting up HTML renderers alongside APIs seems to work.However, when tere are objects to return the same endpoint fails with the following error:</p>
  
  <pre><code>ValueError: dictionary update sequence element #0 has length XX; 2 is required
  </code></pre>
  
  <p>Where <code>XX</code> is the number of attributes the object has.</p>
  
  <p><a href="http://www.django-rest-framework.org/api-guide/renderers/#varying-behaviour-by-media-type" rel="nofollow noreferrer">This</a> documentation section suggests the view function should act slightly differently when returning an HTML <code>Response</code> object, but I assume this is done by DRF's builtin views when necessary, so I don't think that's the issue.</p>
  
  <p><a href="https://stackoverflow.com/questions/24359077/context-aware-browsable-api-rendering-in-django-rest">This</a> stackoverflow Q/A also looks relevant but I'm not quite sure it's the right solution to my problem.</p>
  
  <p>How can I make my <code>ModelViewSet</code>s work with both HTML and JSON renderers?
  Thanks!</p>