title: Django - dynamic success_url in UpdateView
body: <p>I want my user to be able to see a page, update that page, and then be returned to that page or continue making more edits. </p>
  
  <p>Here's the view to show the information:</p>
  
  <pre><code>    # urls.py      
  url(r'^gameview/$', views.GameView.as_view(template_name='matchview.html'), name='GameView')
  
  # Views.py
  class GameView(generic.TemplateView):
      template_name = "matchview.html"
  
      def get_context_data(self, **kwargs):
          context = super(GameView, self).get_context_data(**kwargs)
          q = self.request.GET.get('match')
          context['report'] = GameNotes.objects.filter(game=q)
          context['game'] = Schedule.objects.get(match=q)
          context['gamepic'] = Photo.objects.filter(game=q)
          return context    
  </code></pre>
  
  <p>So now they want to add information about a game. I use an UpdateView</p>
  
  <pre><code>class GameView(generic.TemplateView):
      template_name = "matchview.html"
  
  def get_context_data(self, **kwargs):
      context = super(GameView, self).get_context_data(**kwargs)
      q = self.request.GET.get('match')
      context['report'] = GameNotes.objects.filter(game=q)
      context['game'] = Schedule.objects.get(match=q)
      context['gamepic'] = Photo.objects.filter(game=q)
      return context
  </code></pre>
  
  <p>When the user finishes updating in the latter view, they should be returned to the former on the exact same team. <a href="https://stackoverflow.com/questions/26897050/django-success-url-using-kwargs">This post</a> helped me move in the right direction insofar as using 'get_success_url', but I'm still stuck because I don't think I'm using kwargs. Everything I've tried has resulted in errors. </p>
  
  <p>(My (gulp) thought is that I should re-write the urls to use PKs so that this stuff is easier, but I wanted to make sure)</p>
  
  <p>EDIT:
  My fugly attempt (Note: I  Have two submit buttons, one to update and one to update and add notes).</p>
  
  <pre><code>     def form_valid(self, form):
      if form.is_valid():
          form.save()
      if 'submit' in self.request.POST:
          q = self.request.GET.get('match')
          return reverse_lazy('TeamView', args=(q))
      else:
          return render('addnotes', {'game' : q})
  </code></pre>
  
  <p>SOLUTION:</p>
  
  <p>Learned how to use URL Parameters and kwargs:
  (for anyone new like me, self.kwargs.get is brilliant)</p>
  
  <pre><code>def get_success_url(self, **kwargs):
          q = self.kwargs.get('match')
          if "submit" in self.request.POST:
          url = reverse('GameView', args={q : 'match'})
          else:
              url = reverse('AddNotes', args={q : 'match'})
          return url
  </code></pre>