title: Mongodb error in Django using Djongo : pymongo.errors.OperationFailure: unsupported type in filter
body: <p>I am trying to connect a Django project to a MongoDB cluster and when running:</p>
  
  <pre><code>py manage.py runserver
  </code></pre>
  
  <p>or</p>
  
  <pre><code>py manange.py migrate
  </code></pre>
  
  <p>It keeps showing the same error :</p>
  
  <pre><code>Watching for file changes with StatReloader
  Performing system checks...
  
  System check identified no issues (0 silenced).
  Exception in thread django-main-thread:
  Traceback (most recent call last):
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
      self.run()
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run
      self._target(*self._args, **self._kwargs)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
      fn(*args, **kwargs)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 120, in inner_run
      self.check_migrations()
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 453, in check_migrations
      executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
      self.loader = MigrationLoader(self.connection)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__
      self.build_graph()
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph
      self.applied_migrations = recorder.applied_migrations()
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations
      if self.has_table():
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
      return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\introspection.py", line 48, in table_names
      return get_names(cursor)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\introspection.py", line 43, in get_names
      return sorted(ti.name for ti in self.get_table_list(cursor)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\djongo\introspection.py", line 46, in get_table_list
      for c in cursor.db_conn.collection_names(False)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\database.py", line 715, in collection_names
      nameOnly=True, **kws)]
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\database.py", line 677, in list_collections
      **kwargs)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\database.py", line 631, in _list_collections
      session=tmp_session)["cursor"]
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\database.py", line 514, in _command
      client=self.__client)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\pool.py", line 579, in command
      unacknowledged=unacknowledged)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\network.py", line 150, in command
      parse_write_concern_error=parse_write_concern_error)
    File "C:\Users\marlo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymongo\helpers.py", line 155, in _check_command_response
      raise OperationFailure(msg % errmsg, code, response)
  pymongo.errors.OperationFailure: unsupported type in filter
  </code></pre>
  
  <p>My setting.py configuration is:</p>
  
  <pre><code>DATABASES = {
  'default': {
      'ENGINE': 'djongo',
      'NAME': 'database_django',
      'HOST': 'mongodb+srv://xxxxxx:aaaaaa@isssgeneral-sfm0v.mongodb.net/test?retryWrites=true&amp;w=majority',
      'PORT': 27017,
      'USERNAME': 'xxxxxx',
      'PASSWORD': 'aaaaaa' 
  }
  }
  </code></pre>
  
  <p>My python environment is the following:</p>
  
  <pre><code>pymongo            3.7.0
  Django             2.2.2 
  djongo             1.2.32
  sqlparse           0.2.4
  dnspython          1.16.0
  </code></pre>
  
  <p>I already tried with <a href="https://stackoverflow.com/questions/56280057/pymongo-errors-operationfailure-unsupported-type-in-filter">this post</a> solution that suggests to downgrade the pymongo to 3.5.1 version, which already tried but did not worked. In fact, the project worked previously in the pymongo==3.7 version (the one I have in the envionment at the moment). </p>
  
  <p>I have configured this Django project to connect to the local server and it works, apparently there is something about the host name that does not fit. There is no problem with cluster configuration (I think), since I have a Jupyter Notebook that connects directly to the same cluster.</p>
  
  <p>Really does not know what happened to my project that suddenly stopped connecting to my Mongodb cluster. Could anyone assist me to find the solution for this problem?</p>
  
  <p>Thank you community.</p>