I would like to create a table that lists the rows from a small database (7 rows including header, 3 columns) to an HTML table. I am working in Django and have checked "myapp"views.py, "myapp".urls, and the base.html. I also checked myprojects url settings and did not see anything.
Any help would be great.
Windows 10 Django 2.2.7 Python 3.8
My code is below:
my\app view.py
def repList(request):
all_objects_Rep=Rep.objects.all()
context={'all_objects_Rep': all_objects}
return render (request, 'base.html', context)
myproject\urls.py
urlpatterns = [
path('', include('page.urls')),
path('rep/', include('page.urls', namespace='reps')),
path('home/', include('page.urls', namespace='home')),
path('results/', include('page.urls', namespace='results')),
path('admin/', admin.site.urls),
myapp\urls.py
app_name = 'page'
urlpatterns = [
path('', views.homepage_view, name='homepage_view'),
path('Rep/', views.repList, name='repList'),
path('userInput/', views.userInput, name ='User Input'),
path('results/', views.results_view, name='results_view'),
myapp\base.html
<div class ="RepList">
{% block repList %}
<table>
<tr>
<th>District</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
{% for x in all_objects_Rep %}
<tr>
<td>{{ x.District }}</td>
<td>{{ x.f_name }}</td>
<td>{{ x.l_name }}</td>
</tr>
{% endfor %}
{% endblock %}
</table>
</div>```