builtins.ValueError when redirect with 2 kwargs
<p>I want to perform a redirect in one of my view, and I'm facing an error with not many details.</p>

<p>My urls.py:</p>

<pre><code>urlpatterns = [
    url(
            regex=r'^(?P&lt;pk&gt;[0-9]+)/$',
            view=views.SheetDetailView.as_view(),
            name='detail'
        ),
    url(
            regex=r'^(?P&lt;pk&gt;[0-9]+)/branch/(?P&lt;branch_slug&gt;[a-zA-Z0-9-]+)/$',
            view=views.SheetDetailView.as_view(),
            name='detail'
        ),

]
</code></pre>

<p>My view</p>

<pre><code>class SheetDetailView(LoginRequiredMixin, UserIsLinkedToSheetMixin, UserPassesTestMixin, DetailView):
    model = Sheet
    def get_context_data(self, **kwargs):
        context = super(SheetDetailView, self).get_context_data(**kwargs)
        #if no branch is requested, show the master
        if 'branch_slug' in self.kwargs:
            branch = self.get_object().get_branch(self.kwargs['branch_slug'])
            context['branch']=branch
            return context
        else:
            # redirect to master                    
            sheet_id = self.get_object().pk
            branch_slug = self.get_object().get_master().slug                    
            return redirect(reverse('sheets:detail', kwargs={'pk':sheet_id, 'branch_slug':branch_slug}), permanent=False)
</code></pre>

<p>And my error message:</p>

<pre><code>Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 177, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 230, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 289, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/usr/local/lib/python3.5/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/site-packages/six.py", line 686, in reraise
    raise value
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 174, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 172, in get_response
    response = response.render()
  File "/usr/local/lib/python3.5/site-packages/django/template/response.py", line 160, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.5/site-packages/django/template/response.py", line 137, in rendered_content
    content = template.render(context, self._request)
  File "/usr/local/lib/python3.5/site-packages/django/template/backends/django.py", line 92, in render
    context = make_context(context, request)
  File "/usr/local/lib/python3.5/site-packages/django/template/context.py", line 291, in make_context
    context.push(original_context)
  File "/usr/local/lib/python3.5/site-packages/django/template/context.py", line 61, in push
    return ContextDict(self, *dicts, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/django/template/context.py", line 20, in __init__
    super(ContextDict, self).__init__(*args, **kwargs)
ValueError: dictionary update sequence element #0 has length 0; 2 is required
</code></pre>

<p>When I print out the <code>reverse()</code> result and paste it into my browser, everything is OK.</p>