1. create a project site
2. create a views.py file by linux command: $ touch views.py
3. edit views.py file: $ pico views.py
After editing the file:
control + O to save
control +X to exit editing
request is a default instance in view function. No matter use it or not, the function must have 1 request instance
views.py should be placed in the same folder as urls.py
4. view the file: $ cat views.py
How django process a request:
- A request comes in to /hello/.
- Django determines the root URLconf by looking at the ROOT_URLCONF setting.
- Django looks at all of the URLpatterns in the URLconf for the first one that matches /hello/.
- If it finds a match, it calls the associated view function.
- The view function returns an HttpResponse.
- Django converts the HttpResponse to the proper HTTP response, which results in a Web page.