Question: I'm new to Django, and trying to build a small project; currently trying to understand HttpResponseRedirect, which is not working in this case.

Here's my views.py

```
def user_login(request):
if request.method == 'POST':
    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user:
        if user.is_active:
            login(request, user)
            #return index(request)
            HttpResponseRedirect('/main/')
else:
    render(request, 'main/login.html',{})   

```

here's urls.py in the main app

```
urlpatterns = patterns('',
        url(r'^$', views.index, name = 'index'),
        # .....................
        url(r'^login/$', views.user_login, name='login'),
        url(r'^logout/$', views.user_logout, name='logout'),
        )

```

and here's login.html

```
        <form id="login_form" method="post" action="/main/login/">
        {% csrf_token %}
        Username: <input type="text" name="username" value="" size="50" /><br />
        Password: <input type="password" name="password" value="" size="50" /><br />
        <input type="submit" value="submit" />

```

It all works fine if I return to the index() view after login(), but when I use HttpResponseRedirect, it just doesn't work, it logs me in successfully but stays on the login page. Even if I put HttpResponseRedirect('/asdf/'), it stays there without throwing an error which it should because there is no asdf route in urls. So, two questions, 1) why redirect is not working? 2) why it's not even throwing an error?

Cheers!

Answer: 
you are 'creating' a HttpResponseRedirect but not return it. try:

```
return HttpResponseRedirect('/main/')

```
`return HttpResponseRedirect('/main/')`

You need to return the response... hope that will help...