I have a form (not a model one) for a rsync front-end type. So I would like that when the user selects the source, it will get deleted from the destination choice. I'm new to python and django so forgive my ignorance. This is my forms.py:
from django import forms
class ChoiceForm(forms.Form):
source = forms.ChoiceField(choices=[(1,"Folder1"), (2,"Folder2"), (3,"Folder3")], widget=forms.RadioSelect(), label="Source")
destination = forms.MultipleChoiceField(choices=[(1,"Folder1"), (2,"Folder2"), (3,"Folder3")], widget=forms.CheckboxSelectMultiple(), label="Destination")
options = forms.MultipleChoiceField(choices=[(1,"Try Only"), (2,"Delete")], widget=forms.CheckboxSelectMultiple(), label="Options")
This is my views.py:
def choice(request):
if request.method == 'POST':
form = ChoiceForm(request.POST)
else:
form = ChoiceForm()
return render_to_response('sync_form.html', {'form': form})
And finally this is the sync_form.html
{% if form.errors %}
<p style="color: red;">
Please correct the error{{ form.errors|pluralize }} below.
</p>
{% endif %}
<form action="" method="post">
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit" name="q">
</form>