#25280: django 1.9 using validators.validate_slug will recreate migrations over 
and
over
-------------------------------+------------------------------------------
     Reporter:  chenull        |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Migrations     |    Version:  master
     Severity:  Normal         |   Keywords:  migrations, validators, slug
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+------------------------------------------
 Using django.core.validators.validate_slug in a model will make the
 migration files on that model increment infinitely, allthough no changes
 has made in the model.
 {{{
 from django.core.validators import validate_slug

 class Organization(models.Model):
     slug = models.SlugField(unique=True, validators=[validate_slug])
 }}}

 `manage.py makemigrations`
 {{{
 Migrations for 'organizations':
   0009_auto_20150815_2151.py:
     - Alter field slug on organization
 Migrations for 'organizations':
   0010_auto_20150815_2151.py:
     - Alter field slug on organization
 Migrations for 'organizations':
   0011_auto_20150815_2158.py:
     - Alter field slug on organization
 Migrations for 'organizations':
   0012_auto_20150815_2158.py:
     - Alter field slug on organization
 }}}

 A quick fix is to workaround this issue is just copy paste the code in
 django.core.validators:
 {{{
 from django.core.validators import RegexValidator

 orgslug_validator = [
     RegexValidator(regex=r'^[-a-zA-Z0-9_]+\Z',
                    message=_("Enter a valid 'slug' consisting of letters,
 "
                              "numbers, underscores or hyphens."),
                    code='invalid_slug')
 ]

 class Organization(models.Model):
     slug = models.SlugField(unique=True, validators=orgslug_validator)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25280>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.c718921daf47b57780cd4362a7bbd0df%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to