Bug #99106 Connector / Python error with Django 3.x
Submitted: 30 Mar 8:35 Modified: 20 Aug 8:55
Reporter: Alastair Mooney Email Updates:
Status: Verified Impact on me:
Category:Connector / Python Severity:S1 (Critical)
Version:8.0.19, 8.0.21 OS:Any
Assigned to: CPU Architecture:Any
Tags: Django, python

[30 Mar 8:35] Alastair Mooney
Having recently upgraded Django from 2.x to 3.x, I noticed that the `mysql.connector.django` backend no longer works. The last version that works is 2.2.11. It breaks with 3.0.

When running `manage.py runserver`, the following error occurs:

django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

How to repeat:
1. Create a project with Django >= 3.0 and Connector / Python == 8.0.19.

2. Set the database backend in `settings.py` to `mysql.connector.django`.

3. Run `manage.py runserver`.

Suggested fix:
Consult the Django 3.0 release notes on the database backend API:

[6 Jun 17:42] Jack Ostroff
Is this perhaps because of lack of python3 support in general?  (I don't use django myself, so I have no easy way to check.)
[6 Jun 17:50] Alastair Mooney
No, both Django and Connector / Python work just fine with Python 3. I can use Connector / Python 2.2.11 and everything works as expected. The issue I believe is more a lack of support for Django 3.x. The `mysql.connector.django` backend needs updating by the looks of it. Would be nice to see this done as soon as possible as it is holding other things back.
[6 Jun 17:56] Alastair Mooney
That should say Django 2.2.11 works just fine with Connector / Python and Python 3. Upgrading Django to 3.x causes the connector to error.
[14 Jul 18:36] Manujith Pallewatte
I added a PR with a fix for this, https://github.com/mysql/mysql-connector-python/pull/62 Please review when possible. 

I'm hoping that it would get released before the project i'm currently working on go live :)
[14 Jul 20:24] MySQL Verification Team
Please try 8.0.21 version. Thanks.
[16 Jul 15:42] Alastair Mooney
This is not resolved. with Django 3.0.8 and Connector / Python 8.0.21, I still get the following error:

django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.

Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

I am updating this to Critical as there is no workaround other than to stay on Django 2.2.11, which is not realistic.

Is there any update on this? May be connected to: https://bugs.mysql.com/bug.php?id=99069
[20 Aug 8:55] MySQL Verification Team
Hello Alastair Mooney,

Thank you for the report and feedback.

[20 Aug 9:06] MySQL Verification Team
- VS 2019, Python 3.7, MySQL Connector/Python 8.0.21 and Django-3.1 asgiref-3.2.10 pytz-2020.1 sqlparse-0.3.1

Attachment: 99106.results.txt (text/plain), 5.41 KiB.