Getting started with django-views
Installation or Setup
Detailed instructions on getting django-views set up or installed.
Django Views are simply the functions that get called when a request is made to a certain URLs.
URL patterns are written in
urls.py file, each URL regex is given a function(Django view) from a
views.py, so when a request is made, that function gets the call, with the HTTP request object, and then you can do whatever fun you want to do with that request.
A simple example of view,
from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html)
Calling the above view from a URL would return the current time, everytime you call the URL assigned to this view.
request object has many parameters related to the HTTP request you get, like headers, request type and more.
Read the official doc with more detailed examples.