title: Django - print all objects attribute values
body: <p><strong>HTML</strong></p>
  
  <pre><code>&lt;thead&gt;
    &lt;tr&gt;
      {% for field in fields %}
      &lt;th&gt;{{ field }}&lt;/th&gt;
      {% endfor %}
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    {% for well in well_info %}
    &lt;tr&gt;
      &lt;td&gt;&lt;p&gt;{{ well.api }}&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;{{ well.well_name }}&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;{{ well.status }}&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;{{ well.phase }}&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;{{ well.region }}&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;{{ well.start_date }}&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;{{ well.last_updates }}&lt;/p&gt;&lt;/td&gt;
    &lt;/tr&gt;
    {% endfor %}
    &lt;tr&gt;
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class WellList_ListView(ListView):
      template_name = 'well_list.html'
      context_object_name = 'well_info'
      model = models.WellInfo
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['fields'] = [field.name for field in models.WellInfo._meta.get_fields()]
          return context
  </code></pre>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>from django.db import models
  from django.urls import reverse
  
  
  # Create your models here.
  class WellInfo(models.Model):
      api = models.CharField(max_length=100, primary_key=True)
      well_name = models.CharField(max_length=100)
      status = models.CharField(max_length=100)
      phase = models.CharField(max_length=100)
      region = models.CharField(max_length=100)
      start_date = models.CharField(max_length=100)
      last_updates = models.CharField(max_length=100)
  
      def get_absolute_url(self):
          return reverse("")
  
      def __str__(self):
          return self.well_name
  </code></pre>
  
  <p>I was able to list all attribute field names by getting context['fields'], but I don't know how to automatically print each objects all attributes values.</p>
  
  <p>So in my html file, I hard-coded all the attribute names, but I want to know if I can to this in a more elegant way, by using for loop. So something like:</p>
  
  <pre><code>&lt;tbody&gt;
    {% for well in well_info %}
    &lt;tr&gt;
      {% for value in attribute_list %}
      &lt;td&gt;&lt;p&gt;{{ well.value }}&lt;/p&gt;&lt;/td&gt;
      {% endfor %}
    &lt;/tr&gt;
    {% endfor %}
    &lt;tr&gt;
  </code></pre>