title: Django: Not allowing newly-created user to log in until he/she is approved by the admin?
body: <p>I am recently trying to develop a website using Django in which a person can make his/her registration in the system but he/she should not be allowed to log in to the system until the admin approves the request. I tried the user.is_active field but the only thing it does is to prevent the new user to have access as admin. In other words, the system gives him/her permission to log in the system. My code is as follows:</p>
  
  <pre><code>#  create a new user but he will be inactive until admin's approval
  user = User.objects.create_user(username=username, password=password)
  user.is_active = False
  </code></pre>
  
  <p>After changing the is_active field of the user to False I try to log in the system using the new user's username and password and the system lets me in. This is my code for the login:</p>
  
  <pre><code>def login(request):
      context = RequestContext(request)
      username = request.POST.get('username', '')
      password = request.POST.get('password', '')
      user = auth.authenticate(username = username, password = password)
  
      if user is not None and request.user.is_active:
          auth.login(request, user)
          print 'login'
          print request.user.username
          print request.user.is_active
          return redirect('app.views.results')
  
      else:
          print 'no login'
          return render(request, 'login.html')
  </code></pre>
  
  <p>When I print the user's username and is_active field, I see that the "is_active" field is True instead of False. Is something wrong with the code or am I missing something?
  Any better approaches to solve the problem will also be welcome and appreciated.</p>