let MySQL Connector 1.1.6 work with Django and South

MySQL Connector Python 1.1.6 was released on 2014-2-19, I use it with Django and South, but South looks like cannot work with the Connector 1.1.6.

Description

First, add pair ‘mysql.connector.django’: ‘mysql’, to variable engine_modules in file south/db/__init__.py .

But, with settings.DEBUG enabled, connector will process all warming as error. So, if we use south command schemamigration app –initial , We will receive the error “PendingDeprecationWarning: Options.module_name has been deprecated in favor of model_name”.

Hotfix1

Suppose we can’t modify the third party package, you can only adjust your code.

Add fellow code to settings.py :

SOUTH_DATABASE_ADAPTERS = {
    'default': 'south.db.mysql'
}

and, add fellow code to project’s __init__.py :

#Below is hotfix for MySQL connector 1.1.6

import warnings

origin_filterwarnings = warnings.filterwarnings

default_param = origin_filterwarnings.__defaults__

default_param = list(default_param[:-1])
default_param.append(True)

origin_filterwarnings.__defaults__ = tuple(default_param)

Hotfix2

If you can modify the third party package, you can use this way.

Add pair ‘mysql.connector.django’: ‘mysql’, to variable engine_modules in file south/db/__init__.py .

in file ‘mysql/connector/django/base.py’ line 61, the call of warnings.filterwarnings , add the parameter append=True

Already report this bug: http://bugs.mysql.com/71806

Leave a Reply

Your email address will not be published. Required fields are marked *