Avoid empty tags to be created
This commit is contained in:
parent
839b935d47
commit
c3a75305cb
|
@ -262,6 +262,7 @@ class Post(models.Model):
|
||||||
my_tags = []
|
my_tags = []
|
||||||
# Create new tags
|
# Create new tags
|
||||||
for tag in tags.split(','):
|
for tag in tags.split(','):
|
||||||
|
if tag == '': continue
|
||||||
tag_slug = slugify(tag)
|
tag_slug = slugify(tag)
|
||||||
found = False
|
found = False
|
||||||
for t in tags_list:
|
for t in tags_list:
|
||||||
|
@ -277,6 +278,7 @@ class Post(models.Model):
|
||||||
# Add new tags
|
# Add new tags
|
||||||
post_tags_list = Tag.objects.filter(post=self.id)
|
post_tags_list = Tag.objects.filter(post=self.id)
|
||||||
for tag in tags.split(','):
|
for tag in tags.split(','):
|
||||||
|
if tag == '': continue
|
||||||
tag_slug = slugify(tag)
|
tag_slug = slugify(tag)
|
||||||
found = False
|
found = False
|
||||||
for t in post_tags_list:
|
for t in post_tags_list:
|
||||||
|
@ -291,6 +293,10 @@ class Post(models.Model):
|
||||||
break
|
break
|
||||||
|
|
||||||
# Remove old tags
|
# Remove old tags
|
||||||
|
if tags == '':
|
||||||
|
for t in post_tags_list:
|
||||||
|
self.tags.remove(t)
|
||||||
|
else:
|
||||||
for t in post_tags_list:
|
for t in post_tags_list:
|
||||||
found = False
|
found = False
|
||||||
for tag in tags.split(','):
|
for tag in tags.split(','):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user