listview django 1

listview django

#Listview is usually a class that 
#- generates context (among things) 
#- or it takes a Model and generates a View (context) for a template  
#- in Django 
from django.views.generic import ListView
from myApp.models import myModel

class myListView(Listview)
	model = myModel
#above two-liner basically creates a view from a model

Here is what the above code is Doing:
1. It’s creating a class called myListView that inherits from ListView
2. It’s telling Django that the model that this view will be based on is myModel
3. It’s telling Django that the template that this view will use is myApp/myModel_list.html

Similar Posts