Index: core/management.py
===================================================================
--- core/management.py	(revision 3138)
+++ core/management.py	(working copy)
@@ -134,7 +134,7 @@
 
     Returns list_of_sql, pending_references_dict
     """
-    from django.db import backend, get_creation_module, models
+    from django.db import backend, connection, get_creation_module, models
     data_types = get_creation_module().DATA_TYPES
 
     opts = klass._meta
@@ -151,6 +151,8 @@
         col_type = data_types[data_type]
         if col_type is not None:
             # Make the definition (e.g. 'foo VARCHAR(30)') for this field.
+            if type(col_type).__name__ == 'function':
+                col_type = col_type(rel_field.__dict__, connection)
             field_output = [style.SQL_FIELD(backend.quote_name(f.column)),
                 style.SQL_COLTYPE(col_type % rel_field.__dict__)]
             field_output.append(style.SQL_KEYWORD('%sNULL' % (not f.null and 'NOT ' or '')))
Index: db/backends/mysql/base.py
===================================================================
--- db/backends/mysql/base.py	(revision 3138)
+++ db/backends/mysql/base.py	(working copy)
@@ -12,7 +12,7 @@
     raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
 from MySQLdb.converters import conversions
 from MySQLdb.constants import FIELD_TYPE
-import types
+import types, re
 
 DatabaseError = Database.DatabaseError
 
@@ -61,6 +61,7 @@
     def __init__(self):
         self.connection = None
         self.queries = []
+        self.server_version = None
 
     def _valid_connection(self):
         if self.connection is not None:
@@ -95,6 +96,14 @@
             return util.CursorDebugWrapper(MysqlDebugWrapper(cursor), self)
         return cursor
 
+    def get_server_version(self):
+        if not self.server_version:
+            if not self._valid_connection():
+                self.cursor()
+            version = re.compile('[\.-]').split(self.connection.get_server_info())
+            self.server_version = tuple(int(x) for x in version[:3]) + tuple(version[3:])
+        return self.server_version
+
     def _commit(self):
         self.connection.commit()
 
Index: db/backends/mysql/creation.py
===================================================================
--- db/backends/mysql/creation.py	(revision 3138)
+++ db/backends/mysql/creation.py	(working copy)
@@ -1,12 +1,19 @@
 # This dictionary maps Field objects to their associated MySQL column
-# types, as strings. Column-type strings can contain format strings; they'll
-# be interpolated against the values of Field.__dict__ before being output.
-# If a column type is set to None, it won't be included in the output.
+# types, as strings. Column-type strings can contain format strings or lambda
+# functions. Any lambda functions will be passed two arguments, the first being
+# Field.__dict__ and the second a database connection, and shoud return a
+# string. In either case, the string will be interpolated against the values of
+# Field.__dict__ before being output. If a column type is set to None, it won't
+# be included in the output.
 DATA_TYPES = {
     'AutoField':         'integer AUTO_INCREMENT',
     'BooleanField':      'bool',
-    'CharField':         'varchar(%(maxlength)s)',
-    'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)',
+    'CharField':         lambda details, connection:
+                             (details['maxlength'] > 255 and connection.get_server_version() < (5, 0, 3) and 'text')
+                             or 'varchar(%(maxlength)s)',
+    'CommaSeparatedIntegerField': lambda details, connection:
+                                      (details['maxlength'] > 255 and connection.get_server_version() < (5, 0, 3) and 'text')
+                                      or 'varchar(%(maxlength)s)',
     'DateField':         'date',
     'DateTimeField':     'datetime',
     'FileField':         'varchar(100)',
@@ -21,7 +28,9 @@
     'PhoneNumberField':  'varchar(20)',
     'PositiveIntegerField': 'integer UNSIGNED',
     'PositiveSmallIntegerField': 'smallint UNSIGNED',
-    'SlugField':         'varchar(%(maxlength)s)',
+    'SlugField':         lambda details, connection:
+                             (details['maxlength'] > 255 and connection.get_server_version() < (5, 0, 3) and 'text')
+                             or 'varchar(%(maxlength)s)',
     'SmallIntegerField': 'smallint',
     'TextField':         'longtext',
     'TimeField':         'time',
