Reputation: 898
I have a Mixin similar to:
class MixinWithArgs(object):
def __init__(self, arg1, arg2):
self.thing1 = arg1
self.thing2 = arg2
and a template view that I'm attempting like so:
class ArgView(MixinWithArgs('one', 'two'), TemplateView):
template_name = 'template.html'
and on page render I get 'init takes 3 values, 4 given'
What am I missing here?
Upvotes: 0
Views: 332
Reputation: 254
You are returning an object in your mixin. When that object is instantiated with the view base classes, it must allow its superclass init args,kwargs to pass through your init, which you cannot as you defined your args already. Remember ordering of subclasses is important, the class farthest from the left gets priority.
TypeError: Error when calling the metaclass bases
This tells you it was impossible to instantiate your view object from your subclasses.
Upvotes: 2