Chapter 3. Forms and Views

In this chapter, we will cover the following topics:

  • Passing HttpRequest to the form
  • Utilizing the save method of the form
  • Uploading images
  • Creating form layout with django-crispy-forms
  • Downloading authorized files
  • Filtering object lists
  • Managing paginated lists
  • Composing class-based views
  • Generating PDF documents
  • Implementing a multilingual search with Haystack

Introduction

When the database structure is defined in the models, we need some views to let the users enter data or show the data to the people. In this chapter, we will focus on the views managing forms, the list view, and views generating an alternative output than HTML. For the simplest examples, we will leave the creation of URL rules and templates up to you.

Get Web Development with Django Cookbook - Second Edition 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.