I have a subclassed form which I want to render a custom max attribute on the input field. However, it doesn't return any form instance in the view and thus doesn't render any input field either:
# views.py
..
custom_max_attribute = qs_aggregates['total_equity']
print(custom_max_attribute) # prints 4000
withdraw_form = WithdrawForm(custom_max_attribute)
print(withdraw_form) # prints nothing
..
# template
..
<div class="field-wrapper">
<div class="field-title">Set your Amount</div>
<div class="withdraw-input-field">{{ withdraw_form.withdraw_amount }}</div> <!-- isnt rendered -->
</div>
..
# forms.py
class WithdrawForm(forms.Form):
"""
A form to withdraw available funds from Farena to the users bank account
"""
def __init__(self, custom_max_attribute, *args, **kwargs):
super().__init__(self, custom_max_attribute, *args, **kwargs)
withdraw_amount = forms.FloatField(widget=forms.NumberInput(attrs={'min': 1, 'max': custom_max_attribute, 'step': 0.01}))