title: Django KeyError 'pk' POST method
body: <p>i have post method in form for sort objects </p>
  
  <pre><code>&lt;form method="post" action="{%  url 'package_dashboard' %}"&gt;
  {% csrf_token %}
      &lt;button  type="submit" name="order_by_title"&gt;sortByName&lt;/button&gt;
      &lt;button  type="submit" name="order_by_date"&gt;sortByDate&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>my views.py</p>
  
  <pre><code>class PackageDashboardView(PackageAccessMixin, ListView):
  model = Package
  template_name = "packages/dashboard.html"
  
  def get_queryset(self):
      queryset = Package.objects.all().order_by('title', 'version__name'). \
          select_related('title', 'version').defer('title__metadata', 'validation', 'translations', 'diff_fields')
      if "order_by_date" in self.request.GET:
          queryset = Package.objects.all().order_by('-started', 'version__name'). \
              select_related('title', 'version').defer('title__metadata', 'validation', 'translations', 'diff_fields')
      elif 'order_by_title' in self.request.GET:
          queryset = Package.objects.all().order_by('title', 'version__name'). \
              select_related('title', 'version').defer('title__metadata', 'validation', 'translations', 'diff_fields')
      return queryset
  </code></pre>
  
  <p>my urls.py</p>
  
  <pre><code>url(r'^packages/$', packages.PackageDashboardView.as_view(), name="package_dashboard"),
  </code></pre>
  
  <p>the error</p>
  
  <blockquote>
    <p>Internal Server Error: /packages/ Traceback (most recent call last):<br>
    File
    "/home/abdel/Desktop/eclair-packager/eclair_env/lib/python3.6/site-packages/django/core/handlers/exception.py",
    line 41, in inner
        response = get_response(request)   File "/home/abdel/Desktop/eclair-packager/eclair_env/lib/python3.6/site-packages/django/core/handlers/base.py",
    line 187, in _get_response
        response = self.process_exception_by_middleware(e, request)   File "/home/abdel/Desktop/eclair-packager/eclair_env/lib/python3.6/site-packages/django/core/handlers/base.py",
    line 185, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)   File "/home/abdel/Desktop/eclair-packager/eclair_env/lib/python3.6/site-packages/django/views/generic/base.py",
    line 68, in view
        return self.dispatch(request, *args, **kwargs)   File "/home/abdel/Desktop/eclair-packager/packager/permission_mixins.py",
    line 20, in dispatch
        return super().dispatch(request, *args, **kwargs)   File "/home/abdel/Desktop/eclair-packager/eclair_env/lib/python3.6/site-packages/django/contrib/auth/mixins.py",
    line 56, in dispatch
        return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)   File "/home/abdel/Desktop/eclair-packager/eclair_env/lib/python3.6/site-packages/django/views/generic/base.py",
    line 88, in dispatch
        return handler(request, *args, **kwargs)   File "/home/abdel/Desktop/eclair-packager/packager/permission_mixins.py",
    line 96, in post
        obj = self.get_package()   File "/home/abdel/Desktop/eclair-packager/packager/permission_mixins.py",
    line 78, in get_package
        return get_object_or_404(Package, pk=self.kwargs['pk'], **kwargs) KeyError: 'pk' [26/Dec/2018 11:35:56] "POST /packages/ HTTP/1.1" 500
    109583</p>
  </blockquote>