diff --git a/README.rst b/README.rst index 8357fea0..b0ea4787 100644 --- a/README.rst +++ b/README.rst @@ -229,6 +229,17 @@ pip command:: $ pip install https://github.com/celery/django-celery-beat/zipball/master#egg=django-celery-beat +Issues with mysql +----------------- + If you want to run ``django-celery-beat`` with MySQL, you might run into some issues. + + One such issue is when you try to run ``python manage.py migrate django_celery_beat``, you might get the following error:: + django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes') + To get around this issue, you can set:: + DJANGO_CELERY_BEAT_NAME_MAX_LENGTH=191 + (or any other value if any other db other than MySQL is causing similar issues.) + max_length of **191** seems to work for MySQL. + TZ Awareness: ------------- diff --git a/django_celery_beat/migrations/0001_initial.py b/django_celery_beat/migrations/0001_initial.py index e882d4d9..efdf1737 100644 --- a/django_celery_beat/migrations/0001_initial.py +++ b/django_celery_beat/migrations/0001_initial.py @@ -4,6 +4,7 @@ from django.db import migrations, models import django.db.models.deletion +from django.conf import settings class Migration(migrations.Migration): @@ -71,8 +72,15 @@ class Migration(migrations.Migration): auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField( - help_text='Useful description', max_length=200, - unique=True, verbose_name='name')), + help_text='Useful description', + max_length=getattr( + settings, + 'DJANGO_CELERY_BEAT_NAME_MAX_LENGTH', + 200 + ), + unique=True, + verbose_name='name' + )), ('task', models.CharField( max_length=200, verbose_name='task name')), ('args', models.TextField( diff --git a/django_celery_beat/models.py b/django_celery_beat/models.py index 599261fa..66e1d43c 100644 --- a/django_celery_beat/models.py +++ b/django_celery_beat/models.py @@ -259,8 +259,14 @@ class PeriodicTask(models.Model): """Model representing a periodic task.""" name = models.CharField( - _('name'), max_length=200, unique=True, - help_text=_('Useful description'), + _('name'), + max_length=getattr( + settings, + 'DJANGO_CELERY_BEAT_NAME_MAX_LENGTH', + 200 + ), + unique=True, + help_text=_('Useful description') ) task = models.CharField(_('task name'), max_length=200) interval = models.ForeignKey( diff --git a/t/proj/settings.py b/t/proj/settings.py index 3e143d8c..0cc4842e 100644 --- a/t/proj/settings.py +++ b/t/proj/settings.py @@ -122,4 +122,5 @@ # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' +DJANGO_CELERY_BEAT_NAME_MAX_LENGTH = 191 DJANGO_CELERY_BEAT_TZ_AWARE = True