title: How to select fields to be displayed in generic ListView class in Django?
body: <p>I'm using Django (v1.7) and I'm looking for a "Django style" way to select the fields to be displayed in a generic.ListView.</p>
  
  <p>Let me provide an example:</p>
  
  <p>In models.py:</p>
  
  <pre><code>class Stuff(generic.models):
      field1 = model.CharField()
      field2 = model.CharField()
      field3 = model.CharField()
  </code></pre>
  
  <p>In views.py:</p>
  
  <pre><code>class StuffList(generic.ListView)
      model = Stuff
  </code></pre>
  
  <p>In template/stuff_index.html</p>
  
  <pre><code>{% for stuff in object_list %}
      Field1: {{ stuff.field1 }}
      Field3: {{ stuff.field3 }}
  {% endfor %}
  </code></pre>
  
  <hr>
  
  <p>Is there a way to indicate in views.py the fields to be displayed? So that views.py and template/stuff_index.html would look like:</p>
  
  <p>views.py:</p>
  
  <pre><code>class StuffList(generic.ListView)
      model = Stuff
      fields = ['field1','field3']     # Or something similar
  </code></pre>
  
  <p>In template/stuff_index.html</p>
  
  <pre><code>{% for stuff in object_list %}
      {% for field in stuff %}
          {{ field.name }}: {{ stuff.field }}     &lt;!-- Or something similar --&gt;
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>Is this way of coding somehow handled by Django framework ? I succedded to have something similar by redefining the returned value of <em>get_queryset()</em> method in StuffList class, but it's not a "smart" solution.</p>