Django 1.8:xview Is Missing A Queryset. Define Xview.model, Xview.queryset,
Solution 1:
There are multiple issues with your code:
You have an
if self.request.method == 'POST':
block in yourget_queryset
method. If that evaluates toFalse
then you fall back to the parentget_queryset
method, which is what triggers the error (because the parent method needs to be given either a model or a queryset, as indicated in the error). So if you try a simple GET request toresult_list/
it will fail because theListView
doesn't have a queryset.You shouldn't be rendering templates from inside the
get_queryset
method. That method should return a queryset and nothing else. This will fail.Your
ResultView
really shouldn't be handling the POSTed form data in the first place. You should be handling that in yourFormView
and then redirecting the user to the appropriate result view by using theFormView
ssuccess_url
parameter as explained in the documentation on form processing.
Post a Comment for "Django 1.8:xview Is Missing A Queryset. Define Xview.model, Xview.queryset,"