Skip to content

Commit

Permalink
make Category.slug unique
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Sep 23, 2019
1 parent ddf1330 commit 0eeeeee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ 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 2.0
==========

* Category.slug becomes unique. You must remove all duplicates in category slugs before running migrations.

New in 1.4
==========

Expand Down
2 changes: 1 addition & 1 deletion categories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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()
Expand Down
18 changes: 18 additions & 0 deletions categories/migrations/0003_auto_20181005_1559.py
Original file line number Diff line number Diff line change
@@ -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', '0002_auto_20170217_1111'),
]

operations = [
migrations.AlterField(
model_name='category',
name='slug',
field=models.SlugField(unique=True, verbose_name='slug'),
),
]

0 comments on commit 0eeeeee

Please sign in to comment.