title: TypeError: cannot unpack non-iterable bool object
body: <p>When I run the code it redirects and showing  </p>
  
  <pre><code>TypeError at /accounts/register cannot unpack non-iterable bool object
  </code></pre>
  
  <p>The problem is when I put the below condition in my code</p>
  
  <pre><code>User.objects.filter(username==username).exists():
  
  User.objects.filter(email=email).exists():
  
  </code></pre>
  
  <p>Please help</p>
  
  <pre><code>from django.shortcuts import render, redirect
  from django.contrib.auth.models import User, auth
  
  
  
  # Create your views here.
  
  def register(request):
  
      if request.method == 'POST':
          last_name = request.POST['Last_name']
          first_name = request.POST['first_name']
          username = request.POST['username']
          email = request.POST['email']
          password1 = request.POST['password1']
          password2 = request.POST['password2']
  
          if password1==password2:
              if User.objects.filter(username==username).exists():
                  print("username taken")
              elif User.objects.filter(email=email).exists():
                  print('email exists')
              else:
                  user = User.objects.create_user(username=username,password=password1,email=email,first_name=first_name,last_name=last_name)
                  user.save()
                  print('User Created')
          else:
              print('password doesnt match')
  
          return redirect('/')
  
  
      else:
          return render(request,'accounts/register.html')
  
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>TypeError: cannot unpack non-iterable bool object
  
  [16/Jul/2019 17:51:22] "POST /accounts/register HTTP/1.1" 500 98878
  
  </code></pre>
  
  <p>Environment:</p>
  
  <pre><code>Request Method: POST
  Request URL: http://127.0.0.1:8000/accounts/register
  </code></pre>
  
  <p>Traceback:</p>
  
  <pre><code>File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\core\handlers\exception.py" in inner
    34.             response = get_response(request)
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\core\handlers\base.py" in _get_response
    115.                 response = self.process_exception_by_middleware(e, request)
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\core\handlers\base.py" in _get_response
    113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "C:\Users\MaqboolThoufeeqT\Desktop\DjangoWork\travello\accounts\views.py" in register
    19.             if User.objects.filter(username==username).exists('True'):
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\db\models\manager.py" in manager_method
    82.                 return getattr(self.get_queryset(), name)(*args, **kwargs)
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\db\models\query.py" in filter
    892.         return self._filter_or_exclude(False, *args, **kwargs)
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\db\models\query.py" in _filter_or_exclude
    910.             clone.query.add_q(Q(*args, **kwargs))
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\db\models\sql\query.py" in add_q
    1290.         clause, _ = self._add_q(q_object, self.used_aliases)
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\db\models\sql\query.py" in _add_q
    1318.                     split_subq=split_subq, simple_col=simple_col,
  
  File "C:\Users\MaqboolThoufeeqT\Envs\djangotest\lib\site-packages\django\db\models\sql\query.py" in build_filter
    1187.         arg, value = filter_expr
  
  Exception Type: TypeError at /accounts/register
  Exception Value: cannot unpack non-iterable bool object
  </code></pre>