O'Reilly logo

The Definitive Guide to Django: Web Development Done Right, Second Edition by Jacob Kaplan-Moss, Adrian Holovaty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Forms

HTML forms are the backbone of interactive Web sites, from the simplicity of Google's single search box to ubiquitous blog comment-submission forms to complex custom data-entry interfaces. This chapter covers how you can use Django to access user-submitted form data, validate it, and do something with it. Along the way, we'll cover HttpRequest and Form objects.

Getting Data from the Request Object

We introduced HttpRequest objects in Chapter 3 when we first covered view functions, but we didn't have much to say about them at the time. Recall that each view function takes an HttpRequest object as its first parameter, as in our hello() view:

from django.http import HttpResponse def hello(request): return HttpResponse("Hello world") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required