O'Reilly logo

Django Unleashed by Andrew Pinkham

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

9.3.3 Webpages to Update Startup and Tag Objects

We could build StartupUpdate and TagUpdate independently of each other, but if we did, we’d find that they are nearly identical. Objects of both classes are identified in views by SlugField values, meaning that the arguments passed and the functions called internally will be identical. Similar to our ObjectCreateMixin seen earlier in this chapter, we now build a class called ObjectUpdateMixin to provide both StartupUpdate and TagUpdate with their behavior.

As we did for ObjectCreateMixin, we define the new mixin class in the organizer/utils.py file.

We can anticipate the needs of our class, creating the form_class, model, and template_name attributes we’ve previously used, as shown in Example 9.55 ...

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