title: django 1.8：XView is missing a QuerySet. Define XView.model, XView.queryset,
body: <p>I am getting error when go to the url: /result_list.html. But there is indeed queryset in the views.py, so what could be other reasons? Thanks in advance. The function is based on the form submitted by user, then filter the database and show the form entry and database result in the result_list.html.</p>
  
  <p><strong>Traceback</strong></p>
  
  <pre><code>File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\core\handlers\base.py" in get_response
    132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\views\generic\base.py" in view
    71.             return self.dispatch(request, *args, **kwargs)
  File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\views\generic\base.py" in dispatch
    89.         return handler(request, *args, **kwargs)
  File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\views\generic\list.py" in get
  159.         self.object_list = self.get_queryset()
  File "C:\Users\user\Desktop\SCOR\result\views.py" in get_queryset
  70.         return super(ResultView,self).get_queryset()
  </code></pre>
  
  <p>File "C:\Python27\lib\site-packages\django-1.8.3-py2.7.egg\django\views\generic\list.py" in get_queryset
      44. 'cls': self.<strong>class</strong>.<strong>name</strong><br>
      Exception Type: ImproperlyConfigured at /result_list/
      Exception Value: ResultView is missing a QuerySet. Define ResultView.model, ResultView.queryset, or override ResultView.get_queryset().</p>
  
  <p>Here below is the snippets:</p>
  
  <p><strong>url</strong></p>
  
  <pre><code>from result.views import ResultView,InputFormView
  from django.views.generic import TemplateView,FormView,ListView
  
  urlpatterns = patterns('',    
      url(r'^result_list/$',ResultView.as_view(),name='result'),
      url(r'^input/$',InputFormView.as_view(),name='input'), 
  )
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from result.forms import InputForm
  from result.models import Result,Input
  from django.views.generic.list import ListView
  from django.views.generic import FormView
  ....
  
  @csrf_exempt
  
  class InputFormView(FormView):
      template_name = 'inputform.html'
      form = InputForm
  
      def get_success_url(self):  /*redirect to result page with submitted form information*/
          return ''.join(
              [
                  reverse('dupont'),
                  '?company=',self.request.POST.get('company'),
                  '?region=',self.request.POST.get('region')
              ]
          )
  
  class ResultView(ListView):
      context_object_name = 'result_list'
      template_name = 'result_list.html'
  
      def get_context_data(self, **kwargs):
          context = super(ResultView, self).get_context_data(**kwargs)
          return context
  
      def get_queryset(self):
          if self.request.method == 'POST':
              form = InputForm(self.request.POST)
              if form.is_valid():
                  company = form.cleaned_data['company']
                  region = form.cleaned_data['region']
  
  /---Based on form entry, do the filter on the database-----/
  
                  queryset=Result.objects.filter(region=region,company=company)
                  sales=Result.objects.filter(queryset).aggregate(Sum('sales'))
                  employee=Result.objects.filter(queryset).aggregate(Sum('employee'))
                  departments=Result.objects.filter(queryset).aggregate(Sum('departments'))
  
                  form.save()
  
                  return render(request,'result_list.html',{'company':company},{'region':region},{'employee':employee},{'sales':sales},{'departments':departments})
  
              else:
                  print form.errors
          else:
              form=InputForm()                   
          return super(ResultView,self).get_queryset()
  </code></pre>
  
  <p><strong>result_list.html</strong></p>
  
  <pre><code>&lt;div class="basicinfo"&gt;         &lt;!--Entry Form information submitted by user--&gt;
  
      &lt;table border="1" cellpadding="1"&gt;
      &lt;tr&gt;
          &lt;td align="left"&gt;Company&lt;/td&gt;
          &lt;td&gt;{{company}}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td align="left"&gt;Region&lt;/td&gt;
          &lt;td&gt;{{region}}&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  
  &lt;!--Showing the filtered result in database--&gt;  
  &lt;td&gt;&lt;table border="0" cellspacing="10" cellpadding="10"&gt;
  &lt;tr&gt;&lt;b&gt;Sales&lt;/b&gt;&lt;/tr&gt;
  &lt;td bgcolor="#F0F0F0"&gt; {{sales}}&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;&lt;b&gt;Employee&lt;/b&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td bgcolor="#F0F0F0"&gt; {{employee}}&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;&lt;b&gt;Departments&lt;/b&gt;&lt;/tr&gt;
  &lt;td bgcolor="#F0F0F0"&gt; {{departments}}&lt;/td&gt;
  &lt;/td&gt;&lt;/table&gt;
  </code></pre>
  
  <p><strong>Version 2.0 views.py as per solarissmoke' and pythad's suggestion</strong></p>
  
  <pre><code>class InputFormView(FormMixin,DetailView):
      template_name = 'inputform.html'
      form = InputForm
  
      def post(self, request, *args, **kwargs):
          self.object = self.get_object()
          form=self.get_form()
          if form.is_valid():
              return self.form_valid(form)
          else:
              return self.form_invalid(form)
              print form.errors
  
      def form_valid(self, form):
          company = form.cleaned_data['company']
          region = form.cleaned_data['region']
  
          return super(ResultView,self).form_valid(form) 《Q1:---If here to return to ResultView or InputFormView?---&gt;
  
      def get_success_url(self):   #Redirect to result_list.html
          return reverse('result', kwargs={'pk': self.object.pk})
  
  
  class ResultView(MultipleObjectMixin,DetailView):
      context_object_name = 'result_list'
      template_name = 'result_list.html'
  
      &lt;---Q2: How can I get the form data entry from InputFormView?--&gt;
  
      def get(self, request, *args, **kwargs):
          view = InputFormView.as_view()
          self.object = self.get_object(queryset=Result.objects.filter(company=company,region=region))            
          return super(Result, self).get(request, *args, **kwargs)
  
      def get_context_data(self, **kwargs):
          context = super(ResultView, self).get_context_data(**kwargs)
          context['InputFormView']= self.object
          return context
  
  
      def get_queryset(self):
  
  &lt;--Error!-- this sentence is where reports error as "global name company,region not defined"--&gt;
  
          queryset=Result.objects.filter(company=company,region=region)
          sales=Result.objects.queryset.aggregate(Sum('sales'))
          employee=Result.objects.queryset.aggregate(Sum('employee'))
          departments=Result.objects.queryset.aggregate(Sum('departments'))
  
          return self.object.all()  
  </code></pre>