diff --git a/boards/migrations/0060_auto_20170227_1738.py b/boards/migrations/0060_auto_20170227_1738.py new file mode 100644 --- /dev/null +++ b/boards/migrations/0060_auto_20170227_1738.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-02-27 15:38 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('boards', '0059_auto_20170227_1156'), + ] + + operations = [ + migrations.AlterField( + model_name='tag', + name='name', + field=models.CharField(db_index=True, max_length=100), + ), + ] diff --git a/boards/migrations/0061_auto_20170227_1739.py b/boards/migrations/0061_auto_20170227_1739.py new file mode 100644 --- /dev/null +++ b/boards/migrations/0061_auto_20170227_1739.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-02-27 15:39 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('boards', '0060_auto_20170227_1738'), + ] + + operations = [ + migrations.AlterField( + model_name='tag', + name='name', + field=models.CharField(db_index=True, max_length=100, unique=True), + ), + migrations.AlterField( + model_name='tagalias', + name='name', + field=models.CharField(db_index=True, max_length=100), + ), + ] diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -25,7 +25,7 @@ class TagAlias(models.Model, Viewable): app_label = 'boards' ordering = ('name',) - name = models.CharField(max_length=100, db_index=True, unique=True) + name = models.CharField(max_length=100, db_index=True) locale = models.CharField(max_length=10, db_index=True) parent = models.ForeignKey('Tag', null=True, blank=True, @@ -50,10 +50,10 @@ class TagManager(models.Manager): def get_by_alias(self, alias): tag = None - try: - tag = TagAlias.objects.get(name=alias).parent - except TagAlias.DoesNotExist: - pass + aliases = TagAlias.objects.filter(name=alias).all() + if aliases: + tag = aliases[0].parent + return tag