Django views are MVC views; they control rendering (typically through templates), and the data displayed.
Django views are MVC views; they control rendering (typically through templates) and the data displayed.
It is possible to create generic views, which are specialised on various parameters (frequently model classes), which are simply paired with an appropriate template to create a complete page.
The separation from the template system also makes it very easy to create output in different formats, or use one view for several, quite different looking pages (usually with similar data).
There are two types of views: the Class based view (CBV for short) and Function based views (FBV). The use cases differ for each one and whilst later versions of Django advocate the use of Class based views the Function based views aren't fully deprecated.
CBV's enables better code reuse, inheritance and mixins. Further reading can be found here
An example of a Class based view:
from django.views.generic import UpdateView
from myapp.models import Author
class AuthorUpdate(UpdateView):
model = Author
fields = ['name']
template_name_suffix = '_update_form'
An example of a Function based view:
def update_account_view(request, account_id):
# Do some account stuff
context = {'account': some_object, 'another_key': 'value'}
return render_to_response('templates/account_update.html',
context,
context_instance=RequestContext(request))