mirror of
https://github.com/MOIS3Y/logs-collector.git
synced 2025-02-01 09:20:52 +01:00
24 lines
656 B
Python
24 lines
656 B
Python
|
class ExtraContextMixin:
|
||
|
"""The class adds additional context
|
||
|
to all child view classes that inherit from it.
|
||
|
Overrides the get_context_data method for CBV
|
||
|
"""
|
||
|
|
||
|
title = 'Collector'
|
||
|
|
||
|
def get_title(self, *args, **kwargs):
|
||
|
"""
|
||
|
Return the class title attr by default,
|
||
|
but you can override this method to further customize
|
||
|
"""
|
||
|
return self.title
|
||
|
|
||
|
def get_context_data(self, **kwargs):
|
||
|
context = {}
|
||
|
try:
|
||
|
context = super().get_context_data(**kwargs)
|
||
|
except Exception:
|
||
|
pass
|
||
|
context['title'] = self.get_title()
|
||
|
return context
|