Chapter 4. Creating the Initial Views

What You’ll Learn in This Hour

  • How to configure the initial URLconf file
  • How to handle HTTP requests
  • How to display web pages using the HttpResponse object
  • How to configure URL patterns to enable a view
  • How to add URL-based arguments to a view

This hour shows you how to create and configure the initial views for your projects. Django requires some initial configuration to enable views. As soon as views are enabled through the URLconf file, they are simple to use and powerful.

This hour also shows you how to handle HTTP requests and send HTTP responses directly from your views.

Setting Up the URLconf File

URL configuration of a Django website begins with the ROOT_URLCONF setting in the settings.py file. The

Get Sams Teach Yourself Django in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.