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_querysetmethod. If that evaluates toFalsethen you fall back to the parentget_querysetmethod, 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 theListViewdoesn't have a queryset.You shouldn't be rendering templates from inside the
get_querysetmethod. That method should return a queryset and nothing else. This will fail.Your
ResultViewreally shouldn't be handling the POSTed form data in the first place. You should be handling that in yourFormViewand then redirecting the user to the appropriate result view by using theFormViewssuccess_urlparameter 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,"