Reputation: 22113
The get_context_data
of attribute of class object.
I encounter PasswordContextMixin
in django/contrib/auth/views.py
class PasswordContextMixin:
extra_context = None
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'title': self.title,
**(self.extra_context or {})
})
return context
I am confused with context = super().get_context_data(**kwargs)
, because it equals to context = object.get_context_data(**kwargs)
In [15]: getattr(object, 'get_context_data')
AttributeError: type object 'object' has no attribute 'get_context_data'
How to understand this?
Upvotes: 2
Views: 522
Reputation: 599926
As the name says, this class is a mixin. It is intended to be used with a view class, specifically a subclass of TemplateView, which will define get_context_data
.
Upvotes: 5