title: Django login gives http 500 error
body: <p>So I'm making a login system for my Django application. It works on my dev side absolutely fine, but in prod it doesn't work if I submit the correct username and password (It gives a 500 error). I'm not sure which of the two lines I've pointed out in views.py is the issue, but I figure it must be one of those two since if I do enter an incorrect user then I get redirected fine, even in prod.</p>
  
  <p>The code on my dev and prod side are EXACTLY the same - the only difference is in the settings</p>
  
  <pre><code>   DEBUG = True
     ALLOWED_HOSTS = []
  </code></pre>
  
  <p>^ The above is my dev settings, but in prod DEBUG is False and ALLOWED_HOSTS has been filled out with the appropriate names.</p>
  
  <p>In views.py:</p>
  
  <pre><code>def user_login(request):
  if request.method == "POST":
      username = request.POST['username']
      password = request.POST['password']
      user = authenticate(username=username, password=password)
      if user is not None and user.is_active:
          login(request=request, user=user) &lt;- This line
          return render(request, 'site/homepage.html') &lt;- Or this line
      else:
          return render(request, 'site/login.html', {'incorrect': True})
  else:
      return render(request, 'site/login.html', {})
  </code></pre>
  
  <p>In login.html:</p>
  
  <pre><code>{% block content %}
  {% if user.is_authenticated %}
  &lt;div class="title"&gt;
      &lt;h2&gt;Error&lt;/h2&gt;
  &lt;/div&gt;
  &lt;p&gt;You have already logged in, {{ user.firstname }}. Please logout to login as another user!&lt;/p&gt;
  {% else %}
  &lt;div class="title"&gt;
      &lt;h2&gt;Login&lt;/h2&gt;
  &lt;/div&gt;
  {% if incorrect %}
  &lt;p&gt;You have entered the wrong username and/or password.&lt;br /&gt;
  Please try again&lt;/p&gt;
  {% elif unauthorised %}
  &lt;p&gt;You must login before trying to access that page!&lt;br /&gt;&lt;/p&gt;
  {% endif %}
  &lt;form id="login_form" method="post" action="#"&gt;
  {% csrf_token %}
  &lt;label&gt;Username: &lt;input type="text" name="username" value="" size="50" /&gt;&lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;Password: &lt;input type="password" name="password" value="" size="50" /&gt;&lt;/label&gt;
  &lt;br /&gt;
  
  &lt;input type="submit" value="submit" /&gt;
  &lt;/form&gt;
  {% endif %}
  {% endblock %}
  </code></pre>