Request and Response Objects
Last updated
Was this helpful?
Last updated
Was this helpful?
Django uses request and response objects to pass state through the system.
Django creates an HttpRequest (contains metadata about the request) object when a page is requested
Django loads the appropriate view, passing the HttpRequest as the first argument to the view function
Each view is responsible for returning an HttpResponse objec
class HttpRequest
A string representing the HTTP method used in the request.
This is guaranteed to be uppercase.
ex)
A dictionary-like object containing all uploaded files.
Each key in FILES is the name from the <input type="file" name="">
.
Each value in FILES is an UploadedFile.
FILES will only contain data if the request method was POST and the <form>
that posted to the request had enctype="multipart/form-data"
.
Otherwise, FILES will be a blank dictionary-like object.
class HttpResponse
In contrast to HttpRequest objects, which are created automatically by Django, HttpResponse objects are your responsibility.
Each view you write is responsible for instantiating, populating, and returning an HttpResponse.
The HttpResponse class lives in the django.http module.
Acts just like HttpResponse but uses a 400 status code.
Acts just like HttpResponse but uses a 404 status code.
Acts just like HttpResponse but uses a 403 status code.
Like HttpResponse, but uses a 405 status code.
The first argument to the constructor is required: a list of permitted methods (e.g. ['GET', 'POST']).
+
:
์ฅ์
ํ๋์ ๋ค์์ผ๋๊น ๋น ๋ฅด๊ฒ ๊ฐ๋ฐ ๊ฐ๋ฅ
๋จ์
ํ์ฅ์ด ์ด๋ ค์