This is what I want to achieve:
well_list.html
<thead>
<tr>
{% for item in well_info %}
<th>item</th>
{% endfor %}
</tr>
</thead>
project/urls.py
from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import TemplateView
from django.urls import path, re_path, include
from eric_base import views
urlpatterns = [
path('contextual/', include('eric_base.urls')),
path('well_list/', views.well_list)
]
views.py
from django.shortcuts import render
from django.views.generic import View, TemplateView, ListView, DetailView, CreateView, UpdateView, DeleteView
from . import models
class WellInfoListView(ListView):
template_name = 'well_list.html'
context_object_name = 'well_info'
model = models.WellInfo
models.py
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)
name = models.CharField(max_length=100)
region_location = models.CharField(max_length=100)
spud_date = models.CharField(max_length=100)
well_bore = models.CharField(max_length=100)
rig_name = models.CharField(max_length=100)
status = models.CharField(max_length=100)
def get_absolute_url(self):
return reverse("")
Since I correctly defined context_object_name = 'well_info' in views.py, and I used {% for item in well_info %} in the html, I was expecting that I would get at least something from the model attributes. But when I run this code, I don't get anything. The header row just disappears like the following screenshot:
I want the table headers to have the attribute names defined in models.py, but apparently its not grabbing anything from it. Why is it not grabbing any attributes from models.py, and how can I display only the attribute names as a column header?
So I want the table headers to be:
Api | Name | Region Location | Spud Date | Well Bore | Rig Name | Status
without the values of each keys.


well_list.html(or at least all the relevant portions)? The snippet you posted does not have sufficient information.