Mixins are a special kind of multiple inheritance for a class. You can use them to provide common discrete functionality that, added to other mixins, allows you to define the behavior of a class. There are two main situations to use mixins:
- You want to provide multiple optional features for a class
- You want to use a particular feature in several classes
Django comes with several mixins that provide additional functionality to your class-based views. You can learn more about mixins at https://docs.djangoproject.com/en/2.0/topics/class-based-views/mixins/.
We are going to create a mixin class that includes a common behavior and use it for the course's views. Edit the views.py file of the courses application ...