title: Django redirecting to another view with a bound form
body: <p>I am using <code>Python 2.7</code>, <code>Django 1.3.1</code>.</p>
  
  <p>I am trying to implement a sign in functionality that can be called from arbitrary page and redirects to the same page without any code duplication. The current way that I have is that I have two views: one for the homepage and one for sign in. I want to be able redirect from sign_in view to the home view with a <em>bound form</em>. The main problem is that when the user enters incorrect data (e.g wrong password) I want to redirect to the same page but want to send the context of the original form. I want to be able to do this without explicitly calling the view function since I want to be able to do it from arbitrary page. How do I do this? My current attempts always return an unbound form in case the data is invalid.</p>
  
  <p>My current code is (simplfied):</p>
  
  <p><code>urls.py</code></p>
  
  <pre><code>urlpatterns = patterns('myapp.views',
      url(r'^$', 'index', name='home'),
      url(r'sign_in/^$', 'signin', name='sign_in')
  )
  </code></pre>
  
  <p><code>views.py</code></p>
  
  <pre><code>def index(request, loginForm=LoginForm)
      extra_context = dict()
      extra_context['login_form'] = loginForm
      return direct_to_template(request, 'home.html', extra_context=extra_context)
  
  def signin(request)
      if request.method == 'POST':
          login_form = LoginForm(request.POST, request.FILES)
          if login_form.is_valid():
              # login user 
          redirect_view = reverse('home')
          return redirect(redirect_view, kwargs={'loginForm': login_form})
          # I also tried:  
          # return redirect(redirect_view, loginForm=login_form)
          # what works is:
          # return index(request, loginForm = login_form)
  </code></pre>
  
  <p><code>home.html</code></p>
  
  <pre><code>&lt;form action="{% url sign_in %}" method="post"&gt;
      {{ form.as_p }}
  &lt;/form&gt;
  </code></pre>