-1

When I run python manage.py migrate, I encounter the following error:

File "/home/seyedbet/virtualenv/WanderSight/3.9/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
TypeError: 'staticmethod' object is not callable

Django Version: 4.2, Python Version: 3.9

How can I resolve this?

2
  • Share the migration file. Commented Jun 29, 2024 at 21:56
  • @willeM_VanOnsem I resolved the issue by switching from "mysql.connector.django" to "django.db.backends.mysql" in my settings.py file, and now it works perfectly. This was caused by the database backend configuration in my Django project. Thank you Commented Jun 30, 2024 at 4:42

1 Answer 1

0

I was using "mysql.connector.django" with "mysql-connector-python" for the database backend. This configuration led to the error. Here's what I had in my settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'your_db_name',
        'USER': 'your_db_user',
        'PASSWORD': 'your_db_password',
        'HOST': 'your_db_host',
        'PORT': 'your_db_port',
    }
}

To fix the issue, I switched to "django.db.backends.mysql" with "mysqlclient" as the database backend. Here is the updated configuration that resolved the error:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'your_db_name',
        'USER': 'your_db_user',
        'PASSWORD': 'your_db_password',
        'HOST': 'your_db_host',
        'PORT': 'your_db_port',
    }
}

After making this change, running python manage.py migrate worked without any errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.