I am trying to realize a Class Based ListView
which displays a selection of a table set. If the site is requested the first time, the dataset should be displaye
I think that the error you are getting is because your form doesn't require the name field. So, although the form is valid, the cleaned_data for your name
field is empty.
These could be the problematic lines:
if form.is_valid():
self.show_results = True
self.profiles = Profile.objects.filter(name__icontains=form.cleaned_data['name'])
If I were you, I would try changing the line:
self.profiles = Profile.objects.filter(name__icontains=form.cleaned_data['name'])
to this:
self.profiles = Profile.objects.none()
If you stop receiving errors (and your template receives an empty object_list
), the problem you have is what I said before: name field not required.
Let us know if this doesn't work!