title: Django + SSL + mysql: TypeError: __init__() got an unexpected keyword argument 'server_hostname'
body: <p>I used Djano to build a simple restful API server. SSL has been introduced to the communication between the server and the remote database to enforce security. When the API server tried to write to the database, I got the following error: </p>
  
  <pre><code>File "/app/anaconda/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/app/anaconda/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/app/anaconda/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/app/anaconda/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/app/anaconda/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/app/anaconda/lib/python2.7/site-packages/rest_framework/views.py", line 474, in dispatch
    response = self.handle_exception(exc)
  File "/app/anaconda/lib/python2.7/site-packages/rest_framework/views.py", line 434, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/app/anaconda/lib/python2.7/site-packages/rest_framework/views.py", line 471, in dispatch
    response = handler(request, *args, **kwargs)
  File "/app/anaconda/lib/python2.7/site-packages/rest_framework/decorators.py", line 52, in handler
    return func(*args, **kwargs)
  File "/app/mobile/mpq_backup_response/mpq_backup_response/backup_response/views.py", line 39, in sms
    q.save()
  File "/app/anaconda/lib/python2.7/site-packages/django/db/models/base.py", line 796, in save
    force_update=force_update, update_fields=update_fields)
  File "/app/anaconda/lib/python2.7/site-packages/django/db/models/base.py", line 821, in save_base
    with transaction.atomic(using=using, savepoint=False):
  File "/app/anaconda/lib/python2.7/site-packages/django/db/transaction.py", line 158, in __enter__
    if not connection.get_autocommit():
  File "/app/anaconda/lib/python2.7/site-packages/django/db/backends/base/base.py", line 365, in get_autocommit
    self.ensure_connection()
  File "/app/anaconda/lib/python2.7/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
    self.connect()
  File "/app/anaconda/lib/python2.7/site-packages/django/db/backends/base/base.py", line 171, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/app/anaconda/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 265, in get_new_connection
    conn = Database.connect(**conn_params)
  File "/app/anaconda/lib/python2.7/site-packages/pymysql/__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "/app/anaconda/lib/python2.7/site-packages/pymysql/connections.py", line 688, in __init__
    self.connect()
  File "/app/anaconda/lib/python2.7/site-packages/pymysql/connections.py", line 906, in connect
    self._request_authentication()
  File "/app/anaconda/lib/python2.7/site-packages/pymysql/connections.py", line 1086, in _request_authentication
    self._sock = self.ctx.wrap_socket(self._sock, server_hostname=self.host)
  File "/app/anaconda/lib/python2.7/ssl.py", line 352, in wrap_socket
    _context=self)
  TypeError: __init__() got an unexpected keyword argument 'server_hostname'
  </code></pre>
  
  <p>However, if I went into Djangon's shell interactive environment and wrote directly into the database, everything went smoothly. I don't why this problem happens. </p>