9.2 Webpages for Creating Objects

We start by using the forms we programmed in Chapter 7: Allowing User Input with Forms to create objects in webpages. We first implement a function view, tag_create(), and we do so slowly, because programming a view with a form can be tricky, and getting it wrong can result in a lot of debugging. While not my favored method for implementing form-handling views, the code in the tag_create() view is commonly seen in material related to Django, because it is the code that Django’s documentation uses to introduce form handling in views. Fully understanding this code is thus very useful and serves as a stepping-stone to implementing TagCreate, which uses more explicit code to handle forms and user data.

With a fundamental ...

Get Django Unleashed 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.