How to pass kwargs from different view classes without redundancy?
As of now I have 5+ views that are implementing get_context_data
to pass a title to the respective template. ex:
class SignUpView(FormView):
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data.update({'form_title': 'Sign up'})
return data
class SignInView(LoginView):
template_name = 'center-form.html'
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data.update({'form_title': 'Sign in'})
return data
Each is passing form_title
to template which in turn sets the main template title accordingly.
<head>
<meta charset="utf-8">
<title>{{ form_title }}</title>
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
</head>
Is there a better way to achieve the same thing without this redundancy?