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 ...

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.