0Pricing
Django Academy · Lesson

The HttpRequest Object

Read method, path, GET, and POST data.

Meet the Request Object

Django builds an HttpRequest for every visit and passes it to your view as the first argument, usually named request. 📨

def view(request):
    return HttpResponse("ok")

The HTTP Method

Check request.method to see how the page was asked for. It is a string like GET when reading or POST when submitting data.

if request.method == 'POST':
    save_it()

All lessons in this course

  1. How a Request Reaches Your View
  2. The HttpRequest Object
  3. Returning an HttpResponse
  4. Status Codes and HttpResponse Subclasses
← Back to Django Academy