from django.forms import widgets class AllocationWidget(widgets.RadioSelect): template_name = 'reallocation/widgets/allocation.html' def __init__(self, *args, **kwargs): self.tax = kwargs.pop('tax') super().__init__(*args, **kwargs) def get_context(self, name, value, attrs): con = super().get_context(name, value, attrs) con['tax'] = self.tax return con class BackButton(widgets.Widget): template_name = 'reallocation/widgets/back_button.html' secs = None def get_context(self, name, value, attrs): con = super().get_context(name, value, attrs) con['secs'] = self.secs con['both_btns'] = self.both_btns con['init_disabled'] = self.secs and self.secs > 0 return con