title: Django Generic View UpdateView redirect URL with updated slug
body: <p>This is my updateview which is called by a URL with slug field, e.g.</p>
  
  <pre><code>/mymodel/update/&lt;model_name_slug&gt;/
  </code></pre>
  
  <p><code>MyModel</code> have two fields, <code>name</code> and <code>slug</code>. The slug field <code>&lt;model_name_slug&gt;</code> is automatically generated from <code>MyModel.name</code>. If the user update it, a new slug field will be automatically generated. Then, I want to redirect to this new URL with the newly generated slug field.</p>
  
  <p>The slug field auto-generation is working. It is implemented in the <code>MyModelEditForm</code>. However, the code below won't work. The reason is:</p>
  
  <p>1) User typed this URL to update the existing model</p>
  
  <pre><code>/mymodel/update/example-model
  </code></pre>
  
  <p>2) User changes the Name attribute to <code>"example model changed"</code>. Then slug field will be generated as <code>"example-model-changed"</code> in <code>MyModel</code>.</p>
  
  <p>3) But the URL is not redirected to the <code>"/mymodel/update/example-model-changed"</code>, as <code>get_object()</code> will return <code>None. get()</code> will not be able to compare the newly generated URL <code>"example-model-changed"</code> with original <code>"example-model"</code></p>
  
  <p>What am I missing in below code? I tried to access the newly update object using <code>self.object</code>, but have following error:</p>
  
  <pre><code> MyModelUpdateView object has no attribute 'object'
  </code></pre>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>class MyModelUpdateView(LoginRequiredMixin, UpdateView):
      model = MyModel
      form_class = MyModelUpdateForm
      template_name = 'mymodel/update_mymodel.html'
  
      def get_success_url(self):
          view_name = 'update_mymodel'
          return reverse_lazy(view_name, kwargs={'model_name_slug': self.kwargs.get('model_name_slug','')})
  
      def get_form_kwargs(self):
          '''
          This injects form with keyword arguments.
          '''
          kwargs = super(MyModelUpdateView, self).get_form_kwargs()
          #Update the kwargs with the user_id
          kwargs['user'] = self.request.user
          return kwargs
  
      def get(self, request, *args, **kwargs):
          # self.object = self.get_object()
          if self.request.path != self.object.get_absolute_url():
              return HttpResponseRedirect(self.object.get_absolute_url())
          else:
              return super(MyModelUpdateView, self).get(request,*args, **kwargs)
              # context = self.get_context_data(object=self.object)
              # return self.render_to_response(context)
  
      def get_object(self, queryset=None):
          instance = MyModel.objects.get(slug=self.kwargs.get('model_name_slug',''))
          return instance
  </code></pre>
  
  <p>Even if the get_success_url() is correctly updated, the get_object() seems to have two conflicting requirements:
  1) Be able to fetch the correct object using existing "example-model" slug field;
  2) Be able to fetch the updated object using newly generated "example-model-changed" before the existing URL is not redirected. </p>