I am working on a validation that will require a field be filled in if
it is another field enters on of three values:
For example:
I have a form
class myform(forms.Modelform):
field1 = forms.CharField
field2 = forms.Charfield
field3_type = forms.CharField(choices=choices)
field3 = forms.DateTimeField(required=True)
def __init__(self, field3_type, *args, **kwargs):
super(myform, self_.__init__(*args, **kwargs)
if field3_type in ('option 1', 'option 2', 'option 3'):
self.field['field3'] = forms.DateTiemField(required=False)
The view:
if request.method == 'POST':
form = myform(request.POST)
field3_type = form.cleaned_data['field3_type']
if form.is_valid():
# some form processing
else:
form = myform()
When i try to use the form I get an error at the myform() line stating
that __init__ takes exactyl 2 arguments and only 1 is given.
Any thoughts?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.