mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 06:34:25 -04:00
minor db fix
This commit is contained in:
parent
62089fdb22
commit
844b5c5e20
2 changed files with 16 additions and 15 deletions
|
@ -15,7 +15,7 @@ from django import forms
|
||||||
from ..util import htmldecode, urldecode, ansi_to_html
|
from ..util import htmldecode, urldecode, ansi_to_html
|
||||||
|
|
||||||
from core.models import Snapshot, ArchiveResult, Tag
|
from core.models import Snapshot, ArchiveResult, Tag
|
||||||
from core.forms import AddLinkForm, TagField
|
from core.forms import AddLinkForm
|
||||||
|
|
||||||
from core.mixins import SearchResultsAdminMixin
|
from core.mixins import SearchResultsAdminMixin
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Tag(models.Model):
|
||||||
Based on django-taggit model
|
Based on django-taggit model
|
||||||
"""
|
"""
|
||||||
name = models.CharField(verbose_name="name", unique=True, blank=False, max_length=100)
|
name = models.CharField(verbose_name="name", unique=True, blank=False, max_length=100)
|
||||||
slug = models.SlugField(verbose_name="slug", unique=True, max_length=100)
|
slug = models.SlugField(verbose_name="slug", unique=True, blank=True, max_length=100)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Tag"
|
verbose_name = "Tag"
|
||||||
|
@ -52,7 +52,8 @@ class Tag(models.Model):
|
||||||
if self._state.adding and not self.slug:
|
if self._state.adding and not self.slug:
|
||||||
self.slug = self.slugify(self.name)
|
self.slug = self.slugify(self.name)
|
||||||
|
|
||||||
with transaction.atomic():
|
# if name is different but slug conficts with another tags slug, append a counter
|
||||||
|
# with transaction.atomic():
|
||||||
slugs = set(
|
slugs = set(
|
||||||
type(self)
|
type(self)
|
||||||
._default_manager.filter(slug__startswith=self.slug)
|
._default_manager.filter(slug__startswith=self.slug)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue