Have you wished you could add or edit many records to the database at once? With only a few lines of code, you can add this capability to your application.
- [Instructor] Sometimes you wanna have multiple forms…on the same page,…in order to allow adding many records at once.…For example, say you bought a new album…and wanted to add a dozen songs in one shot,…or you want to edit the last five records…in a database at once with two extra blank forms…so that you can add up to two new records.…This is probably easy to explain if you see it first.…Here's what we're going to create.…This is a form that lets us add…up to five new records at once.…We also have another version of this…where we can update existing records and add new ones.…This takes surprisingly little code.…
Form-sets are what make this so easy.…Let's look at the HTML that generates our form.…The HTML is used by both the create and update form,…and there is not much to it.…We have to include the call to form.management_form.…This will inject some hidden form fields that Django needs.…After that you'll see that we loop through a form variable,…adding the fields for each form.…We're using the exact same models from the last video,…
Django is one of the world's leading web development platforms. This Python web framework makes your app building experience smoother, faster, and easier. It is a key feature behind the success of many start-ups across the world, including Instagram and Nextdoor. This course introduces next-level advanced concepts to help you build your own professional-grade Django applications.
Author Kevin Veroneau starts off by explaining how class-based views—a powerful, but often poorly understood feature—work in Django. Then learn how to create custom middleware to help organize frequently used code. Have you ever wanted to build a complete RESTful API? Find out how to do just that, starting with a basic read-only API and then adding key-based authentication to allow the full range of CRUD functionality. Plus, discover how to use model managers and the Q method to make it easier to get the data we need to our views and clients.
For the finishing touches, dive into the details of caching to improve application performance, and then add custom management commands to help automate routine tasks.
- Extending class-based views
- Creating custom class-based views
- Managing your database with middleware
- Creating template filters and tags
- Building a RESTful API
- Modeling advanced database relationships and queries
- Using a model manager for your application