diff --git a/README.rst b/README.rst index 49d8c54a..a9ee4342 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,11 @@ Django Categories grew out of our need to provide a basic hierarchical taxonomy As a news site, our stories, photos, and other content get divided into "sections" and we wanted all the apps to use the same set of sections. As our needs grew, the Django Categories grew in the functionality it gave to category handling within web pages. +New in 1.8 +========== + +* Category.slug becomes unique. If there are any duplicates in category slugs, the migration will add sequence number to them. + New in 1.7 ========== diff --git a/categories/base.py b/categories/base.py index 29319f4f..88cf62e4 100644 --- a/categories/base.py +++ b/categories/base.py @@ -53,7 +53,7 @@ class CategoryBase(MPTTModel): verbose_name=_('parent'), ) name = models.CharField(max_length=100, verbose_name=_('name')) - slug = models.SlugField(verbose_name=_('slug')) + slug = models.SlugField(verbose_name=_('slug'), unique=True) active = models.BooleanField(default=True, verbose_name=_('active')) objects = CategoryManager() diff --git a/categories/migrations/0004_unique_category_slug.py b/categories/migrations/0004_unique_category_slug.py new file mode 100644 index 00000000..4404566d --- /dev/null +++ b/categories/migrations/0004_unique_category_slug.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.9 on 2018-10-05 13:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0003_auto_20200306_1050'), + ] + + operations = [ + migrations.AlterField( + model_name='category', + name='slug', + field=models.SlugField(unique=True, verbose_name='slug'), + ), + ]