TypeError: объект 'NoneType' не является вызываемым в [class CacheableModel(models.Model):] с Django (2.2.6) и Python 3.8.10

Я получаю ошибку "TypeError: 'NoneType' object is not callable", как показано на рисунке. Любая помощь будет очень признательна!

Traceback (most recent call last):
  File "C:\Mycode\dev-secrets-manager-codepipeline\manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    django.setup()
  File "C:\Python\Python38-32\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python\Python38-32\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "C:\Python\Python38-32\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Mycode\dev-secrets-manager-codepipeline\server\models.py", line 15, in <module>
    class CacheableModel(models.Model):
  File "C:\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 117, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "C:\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 321, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Python\Python38-32\lib\site-packages\django\db\models\options.py", line 204, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "C:\Python\Python38-32\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Python\Python38-32\lib\site-packages\django\db\utils.py", line 202, in __getitem__
    conn = backend.DatabaseWrapper(db, alias)
  File "C:\Users\yhuang\AppData\Roaming\Python\Python38\site-packages\mysql\connector\django\base.py", line 336, in __init__
    super(DatabaseWrapper, self).__init__(*args, **kwargs)
  File "C:\Python\Python38-32\lib\site-packages\django\db\backends\base\base.py", line 102, in __init__
    self.client = self.client_class(self)
TypeError: 'NoneType' object is not callable

код выглядит следующим образом: manage.py

import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings_local")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

models.py

import re
import uuid
from datetime import datetime
from django.db import models
from django.conf import settings
from django.utils.translation import get_language_info


class CacheableModel(models.Model):

    updated = models.DateTimeField(
        auto_now=True,
        db_index=True
    )

    class Meta:
        abstract = True
        get_latest_by = "updated"

    @classmethod
    def latest(cls, **filter_args):
        
        if filter_args:
            query = cls.objects.filter(**filter_args)
        else:
            query = cls.objects.all()
        if query.exists():
            return query.latest().updated
        
        return datetime.now()

Окружающая среда:

python 3.8.10
Django 2.2.6
mysql-connector 2.2.9
mysql-connector-python 8.0.27
mysqlclient  2.0.3
Вернуться на верх