I have a database table that allows you to enter details about a particular person. How can i then list all the entries of that table to show all the people added to the database.
urls.py
url(r'^accounts/loggedin/locations/all/$', 'assessments.views.locations'),
url(r'^accounts/loggedin/locations/get/(?P<location_id>\d+)$', 'assessments.views.location'),
url(r'^accounts/loggedin/locations/create/$', 'assessments.views.create'),
models.py
class People(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
view.py
def people(request):
return render_to_response('dashboard/people.html', {'people': People.objects.all})
people.html
<body>
<h1>People</h1>
{% for p in people %}
<h1><a href="/people/get/{{ people.id }}/">{{ people.first_name }}</a></h1>
{% endfor %}
</body>
</html>
` for each person, with the correct name.
– Lovato Sep 08 '14 at 13:09