I'm learning django 2 and have a problem. I try to inherite some class and have this error: "TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases"
This is my code of 'view.py':
from django.views.generic.base import TemplateView
from generic.mixins import CategoryListMixin
class MainPageView(TemplateView, CategoryListMixin):
template_name = 'mainpage.html'
But i've got this stuck only when 'CategoryListMixin' class is placed at another folder with 'view.py'. If I do like this:
from django.shortcuts import render
from django.views.generic.base import TemplateView
from django.views.generic.base import ContextMixin
class CategoryListMixin(ContextMixin):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['current_url'] = self.request.path
return context
class MainPageView(TemplateView, CategoryListMixin):
template_name = 'mainpage.html'
Everything is okay.
Any resolving like this: Multiple inheritance metaclass conflict didn't help. What could be a problem? Thank you.