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 Oct 6, 2018
1 parent 58ec14f commit 3c1a61a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
2 changes: 1 addition & 1 deletion categories/fixtures/musicgenres.json
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@
"name": "Country pop",
"parent": 142,
"level": 1,
"slug": "country-pop",
"slug": "country-pop-1",
"lft": 100,
"tree_id": 10,
"order": 1
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 3c1a61a

Please sign in to comment.