I am trying to create a login page for my Django website. At first I tried all the built in login functions that Django ships with, however I ran into a problem. My problem is, for the time being the login page has been trying to redirect to the home page. (I have also tried another page, didnt work) Once the user logs in, the redirect page is rendered as an html, however the url stays as /accounts/login/ when it is supposed to be /mobile/ or / and because of this none of the links work, and static files aren't loaded.

Below is my login view code: 

```
def login(request):
        if request.method == "POST":
            redirect_to = request.POST['next']
            print 'method is post'
            form = AuthenticationForm(data=request.POST)
            username = request.POST.get('username', '')
            password = request.POST.get('password', '')
            user = auth.authenticate(username=username, password=password)
            if form.is_valid() and user is not None and user.is_active:
                print 'form is valid'
                netloc = urlparse.urlparse(redirect_to)[1]
                print 'original redirect_to is: ',redirect_to
                # Use default setting if redirect_to is empty
                if not redirect_to:
                    print 'changing redict to default: ', redirect_to
                    redirect_to = settings.LOGIN_REDIRECT_URL

                print 'redirect to is: ',redirect_to
                # Heavier security check -- don't allow redirection to a different
                # host.
                #elif netloc and netloc != request.get_host():
                #    redirect_to = settings.LOGIN_REDIRECT_URL

                # Okay, security checks complete. Log the user in.
                print form.get_user()
                auth.login(request, user)
                print 'user logged in'

                return redirect(reverse('builds.views.mobile_view'))
        else:
            redirect_to = request.REQUEST.get('next')
            form = AuthenticationForm(request)
            c = {
                'next':redirect_to,
                'form': form,
                }

            print 'returning render to response login'
            return TemplateResponse(request,'registration/login.html', context = c)

```

Since the built in login view didn't seem to be working, I figured if i wrote my own it may work, however the problem persisted.

Here is my login html code:

```
<!-- Start of first page: START -->
<div data-role="page" class="type-interior" id="LOGIN" data-theme="a">
    {% if form.errors %}
    <div data-role="header" data-theme="a" data-content-theme="a">
        <h1>Your username and password didn't match. Please try again.</h1>
    </div><!-- /header -->

    {% else %}

    <div data-role="header" data-theme="a" data-content-theme="a">
        <h1>Please Enter Your Username and Password</h1>
    </div><!-- /header -->

    {% endif %}

    <form method="post" action="/accounts/login/" id="login_form">

        <label for="username">User name:</label>
        <input type="text" name="username" value="" id="username">

        <label for="password">Password:</label>
        <input type="password" name="password" value="" id="password">

        <input type="submit" value="Login" id="button"/>

        <input type="hidden" name="next" value="{{ next|escape }}" />

    </form>

    <div data-role="footer" data-theme="a">
        <h4></h4>
    </div>

</div>

```

Please help me! I feel like I have tried everything. Also please tell me if I should include any other code.

EDIT:

OKAY! I have narrowed down the problem to the java script content I am using in my Header of the login page (I am using jquery). The header is:

```
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <title>Install Builds</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="{{ STATIC_URL }}blablahblachname.css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile.structure-1.1.0.min.css" />
    <!--<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>-->
    <link rel="apple-touch-icon-precomposed" href="{{ STATIC_URL }}static/homepage_icon.png" />
    <link rel="icon" href="{{ STATIC_URL }}homepage_icon.png" type="image/vnd.microsoft.icon" />
</head>

```

Is there a work around for this? Or do I have to completely exclude the javascript and thus have a bland looking login page :(