title: How to access related object id in DeleteView
body: <p>I have a DeleteView. In which i want to access related object id. When user make POST request.</p>
  
  <p>View:</p>
  
  <pre><code>class DeletePacketView(LoginRequiredMixin, DeleteView):
  
      model = Packet
      template_name = DELETE_PACKET_TEMPLATE
  
      def get_success_url(self):
  
          # Return to customer home
          return reverse('myapp:view_customer',
                         kwargs={'pk': self.object.customer.id
                                 }
                         )
  
      def post(self, request, *args, **kwargs):
  
          html = """
                 &lt;html&gt;
                     &lt;head&gt;
                         &lt;script&gt;window.onunload = refreshParent; function refreshParent() {
                                 window.opener.location.href=%s;
                                 }
                         &lt;/script&gt;
                     &lt;/head&gt;
                     &lt;body&gt;
                     &lt;h1&gt;object deleted successfully&lt;/h1&gt;
                     &lt;button type="button" onclick="window.close()"&gt;OK&lt;/button&gt;
                     &lt;/body&gt;
                 &lt;/html&gt;
                 """ % reverse('myapp:view_customer',
                                kwargs={'pk': self.object.customer.id
                                        }
                                )
          super(DeletePacketView, self).post(request, *args, **kwargs)
          return HttpResponse(html)
  </code></pre>
  
  <p>But I am getting error when I try to submit form.</p>
  
  <p>Traceback:</p>
  
  <pre><code>Environment:    
  
  Request Method: POST
  Request URL: http://localhost:8000/delete/packet/96/
  
  Django Version: 1.7
  Python Version: 2.7.8
  Installed Applications:
  ('django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'myapp')
  Installed Middleware:
  ('django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware',
   'django.contrib.admindocs.middleware.XViewMiddleware')
  
  
  Traceback:
  File "C:\Users\PrImE\envs\ge\lib\site-packages\django\core\handlers\base.py" in get_response
    111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\PrImE\envs\ge\lib\site-packages\django\views\generic\base.py" in view
    69.             return self.dispatch(request, *args, **kwargs)
  File "C:\Users\PrImE\envs\ge\lib\site-packages\django\utils\decorators.py" in _wrapper
    29.             return bound_func(*args, **kwargs)
  File "C:\Users\PrImE\envs\ge\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
    22.                 return view_func(request, *args, **kwargs)
  File "C:\Users\PrImE\envs\ge\lib\site-packages\django\utils\decorators.py" in bound_func
  
    23.         return super(LoginRequiredMixin, self).dispatch(*args, **kwargs)
  File "C:\Users\PrImE\envs\ge\lib\site-packages\django\views\generic\base.py" in dispatch
    87.         return handler(request, *args, **kwargs)
  File "C:\Users\PrImE\workspace\myproject\repo\dev\myproject\myproject\myapp\views\delete_views\delete_packet_view.py" in post
    66.                               kwargs={'pk': self.object.customer.id
  
  Exception Type: AttributeError at /delete/packet/96/
  Exception Value: 'DeletePacketView' object has no attribute 'object'
  </code></pre>
  
  <p>I am getting this error because the object is deleted. But <code>get_success_url</code> method works fine it is redirecting user to the customer page why not post method is working and how do I access <code>self.object.customer.id</code>??? </p>