title: Django Python redirect after login
body: <p>I know this questions has been answered is one ore another way, but I still cant figure out how to redirect after a user is logged in. I know Django comes with built in websites, but I need a custom login form, which looks like this(this is the HTML):</p>
  
  <pre><code>{% if user.is_authenticated %}
      &lt;!-- Authenticate account menu --&gt;
  {% else %}
      &lt;h3&gt;Login&lt;/h3&gt;
      &lt;form action="/app/login/" method="post" accept-charset="utf-8"&gt;
          &lt;label for="username"&gt;Username&lt;/label&gt;
          &lt;input type="text" name="username" value="" id="username" /&gt;
          &lt;label for="password"&gt;Password&lt;/label&gt;
          &lt;input type="password" name="password" value="" id="password" /&gt;
          &lt;p&gt;&lt;input type="submit" value="Login →"&gt;&lt;/p&gt;
      &lt;/form&gt;
  {% endif %}
  </code></pre>
  
  <p>My views.py looks like that:</p>
  
  <pre><code>from django.http import HttpResponse
  from django.shortcuts import render_to_response
  from django.template import Context, loader
  from django.contrib.auth import authenticate, login
  from django.views.generic.simple import *
  
  def index(request):
  if request.method == 'POST':
          user = authenticate(username=request.POST['username'],                    password=request.POST['password'])
          if user is not None:
              if user.is_active:
                  login(request, user)
                  # success
              if request.POST['next']:
                  return HttpResponseRedirect(request.POST['next'])
              else:
                  return HttpResponseRedirect('/')
          else:
              # disabled account
              return direct_to_template(request, 'inactive_account.html')
      else:
          # invalid login
          return render_to_response("app/index.html")
  return render_to_response("app/index.html")
  </code></pre>
  
  <p>I did not write the code myself entirely. I figured out that the redirect happens in the html file some where here: <code>&lt;form action="/app/login/</code>. But django says it cant find the url. All in all I have to say I am new to web programming+django+python and not totally clear on the concept.
  Thanks for help!!</p>