Hello, SOvians. I have customized one of my forms and now it does not pass the is_valid() test. No form.errors are visible. Any ideas for where I went wrong?
Form:
class SearchForm(forms.Form):
param = forms.CharField(required=False, max_length = 500, label = 'Search for')
sets = forms.ModelMultipleChoiceField(queryset=Set.objects.all())
onlyDiffer = forms.BooleanField(required=False, label = 'Display varying only')
def __init__(self, userN = False, *args, **kwargs):
super(SearchForm,self).__init__(*args,**kwargs)
self.userN = userN
self.fields['sets'].queryset=Set.objects.filter(Q(owner = None) | Q(owner=self.userN))
View:
def search(request):
template = 'search.html'
if request.method == 'POST':
form = SearchForm(request.POST)
if form.is_valid():
(..do search..)
else:
return direct_to_template(request, template, {'form' : SearchForm(), 'errors' : form.errors})
else:
usr = request.user
form = SearchForm(usr)
return direct_to_template(request, template, { 'form': form })
Thank you!