request
object provided by Django as the default argument in views. For those unfamiliar with Django, this web framework is written in Python by experienced developers using a batteries-included concept. For more information regarding this amazing web framework please access:request
object is exposed:Create and activate a virtual environment
Install Django - using PIP
Create the project folder
.
at the end of the command.Create the database and the app tables
Start the application
Update settings to include the new app -config/settings.py
Update routing -config/urls.py
Code out first route and get access to therequest
object
request
object in Django comes with a few interesting properties: How to check the request type in view.
POST
(when we send information to the server, login action for instance):GET
is used to pull information from the server without altering anything. Search is a good example of a GET
request when we try to locate information on Google or Wikipedia. POST
is used to update the information on the server like change the title for a book or register a new item in our service.GET
and POST
is the location of the submitted information. http://myservice.com?search=all_books
List all request headers
GET
and POST
requests populated with all variables sent by the client. We can access the variables by key
or using get()
helper for both cases. Read GET variables
For POST, the process is identical.