0

I have encountered this error about mysql version-
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. (Error copied from error logs in gcloud)I also encountered this same error locally so I applied this solution where I changed the base.py and operations.py files locally on my PC and it worked- Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3 But now I am facing the same issue after deploying the webapp on Google Cloud Platform. Any suggestions on how I can edit the same set of files specified in the other solution on gcloud? Or any other solutions?

Nibrass H
  • 2,403
  • 1
  • 8
  • 14

1 Answers1

0

PyMySQL is not supported officialy by Django.

To work PyMySQL with Django 2.2, it'll have to update the version_info from 1.3.12 to 1.3.13 but as stated in a Github ticket, PyMySQL isn't working with Django 2.2 because they changed the code by using query.decode instead of force_text method.

They said it will be fixed in Django version 3.0 and it seems to work fine in the latest versions after setting pymysql.version_info.

In your settings.py, add the following lines for Django 3.0:

import pymysql
pymysql.version_info = (1, 4, 6, 'final', 0)  # change mysqlclient version
pymysql.pymysql.install_as_MySQLdb()
Nibrass H
  • 2,403
  • 1
  • 8
  • 14
  • So should I update to django 3.0? Wouldn't it cause ambiguities since my whole project is in django 2.2 – Naitik Parmar Feb 25 '20 at 12:35
  • Yes, I think you should update to Django 3.0, because Django 2.2 will not work with PyMySQL, if you want to use PyMySQL, you will have to use version 3.0 or you can use I think version 2.1 – Nibrass H Feb 25 '20 at 14:11
  • Though I had to change the code- `import pymysql pymysql.version_info = (1, 4, 6, 'final', 0) # change mysqlclient version pymysql.install_as_MySQLdb()` thanks anyway – Naitik Parmar Feb 27 '20 at 17:28