I have a form that I've created in Django:
class someForm(forms.Form):...
that takes in a variable, someVariable, in its init function:
def __init__(self, someVariable, *args, **kwargs):
Is it possible for me to use someForm as a field in another form like so?:
class someOtherForm(forms.Form):
sf = someForm(someVariable=self.someVariable)
...
def __init__(self, someVariable, *args, **kwargs)
self.someVariable = someVariable
I think your best bet would be extending the original form like so:
def someForm(forms.Form):
someVariable = ...
...
def __init__(self, someVariable, *args, **kwargs):
self.someVariable = someVariable
def someOtherForm(someForm):
...
def __init__(self, someVariable, *args, **kwargs):
super(SomeOtherForm, self).__init__(someVariable, *args, **kwargs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With