9.2.6 Shortening Organizer Views

At this point, the last four views we have programmed are virtually identical. Your DRY Pavlov response should be through the roof. It’s time to refactor!

In this section, we create a class mixin for TagCreate, StartupCreate, and NewsLinkCreate. We won’t integrate this mixin with PostCreate because we want to maintain app encapsulation. If this bothers you, I’ll let you in on a secret: the content of Chapter 17 will allow us to remove all of this code.

Recall from Chapter 7 that a class mixin is an abstract class that is intended to simply provide behavior to other classes and is never meant to be instantiated itself. The use of this mixin class comes with an important, desirable caveat. The class we are about ...

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.