title: Django redirect to root from a view
body: <p>I am creating a django project. However, I have come across a small hiccup. My urls.py looks like this</p>
  
  <pre><code>url(r'^login/(?P&lt;nextLoc&gt;)$', 'Home.views.login'),
  url(r'^logout/$', 'Home.views.logout'),
  </code></pre>
  
  <p>My views.py in the Home app is as follows:</p>
  
  <pre><code>def login(request,nextLoc):
      if request.method == "POST":
          form = AuthenticationForm(request.POST)
          user=auth.authenticate(username=request.POST['username'],password=request.POST['password'])
          if user is not None:
              if user.is_active:
                  auth.login(request, user)
                  return redirect(nextLoc)
              else:
                  error='This account has been disabled by the administrator. Contact the administrator for enabling the said account'
          else:
              error='The username/password pair is incorrect. Check your credentials and try again.'
  
      else:
          if request.user.is_authenticated():
              return redirect("/profile/")
          form = AuthenticationForm()
          error=''
      return render_to_response('login.html',{'FORM':form,'ERROR':error},context_instance=RequestContext(request))
  
  def logout(request):
      auth.logout(request)
      return redirect('/')
  </code></pre>
  
  <p>Now when I am going to the login page, it is opening up as expected. After I submit the form, I get an error that says that it can't find the module urls. After digging around a bit, I noticed that the redirect("/") actually translates into <code>http://localhost/login/</code> instead of <code>http://localhost/</code>. The same happens in logout, i.e. it tries opening the url <code>http://localhost/logout/</code> instead of <code>http://localhost/</code>. Basically, when the page opened is <code>http://localhost/login</code>, the <code>redirect('/')</code> adds the / to the end of the current url, and voila - I get a url that I didn't expect - <code>http://localhost/login/</code>. I cannot get it to redirect to the root of the site using the redirect.</p>
  
  <p>Please help me out with this and if possible also explain the cause of this irrational behavior of Django</p>