From the course: Learning Django

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Implement Django views

Implement Django views

From the course: Learning Django

Start my 1-month free trial

Implement Django views

- [Instructor] With our URL routing in place, we can now flesh out our views. First, we'll open the adoptions folder and click on the views.py file. First, we'll flesh out the home view. First this view, we want the page to display a list of pets, with a few basic details about each one. First each pet entry, we'll provide a link to the pet detail view for more information. To accomplish this, the body of the home view will need to fetch all of our pets, using the Django ORM. First, we'll need to import our pet model so that we can use it to query for pets in this way. Therefore, after our existing imports, I'll add a few lines, and then on line four, I'll add from .models import Pet, with a capital P because it's a class. With this imported, we can now use the pet model to make queries. For the home view, let's start by clearing out what we had before in the body. We'll start the implementation of this view with a…

Contents