In object-oriented languages, such as Python, a mixin class can be viewed as an interface with implemented features. When a model extends a mixin, it implements the interface and includes all of its fields, properties, and methods. The mixins in Django models can be used when you want to reuse the generic functionalities in different models multiple times.
Using model mixins
Getting ready
First, you will need to create reusable mixins. A good place to keep your model mixins is in a utils module, such as the one that we will create later in the chapter (along with some typical examples of mixins). If you create a reusable app that you will share with others, keep the model mixins in the reusable app, instead—possibly...