0 votes
in Data Handling by
What is mixin?

1 Answer

0 votes
by

Mixin is a type of multiple inheritance wherein you can combine behaviors and attributes of more than one parent class. Mixins provide an excellent way to reuse code from multiple classes. For example, generic class-based views consist of a mixin called TemplateResponseMixin whose purpose is to define render_to_response() method. When this is combined with a class present in the View, the result will be a TemplateView class.

One drawback of using these mixins is that it becomes difficult to analyze what a child class is doing and which methods to override in case of its code being too scattered between multiple classes.

Related questions

0 votes
asked Nov 2, 2020 in Data Handling by AdilsonLima
0 votes
asked Nov 2, 2020 in Data Handling by AdilsonLima
...