Commit e6c3d1e9 authored by cynddl's avatar cynddl

Fix tags: allow empty 'tags' field & save new tags

parent 21f61095
......@@ -9,3 +9,9 @@ class TagMultipleChoiceField(forms.ModelMultipleChoiceField):
return [self.prepare_value(v) for v in value]
else:
return super(TagMultipleChoiceField, self).prepare_value(value)
def clean(self, value):
value = self.to_python(value)
self.validate(value)
self.run_validators(value)
return value
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-28 13:41
from __future__ import unicode_literals
from django.db import migrations, models
import taggit.managers
class Migration(migrations.Migration):
dependencies = [
('rp', '0012_auto_20170427_1439'),
]
operations = [
migrations.AlterField(
model_name='article',
name='lang',
field=models.CharField(choices=[('FR', 'French'), ('EN', 'English'), ('NA', 'Other')], default='NA', max_length=50, verbose_name='Language'),
),
migrations.AlterField(
model_name='article',
name='tags',
field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
),
]
......@@ -57,7 +57,7 @@ class Article(VoteMixin):
#: priority: True if article have priority
priority = models.BooleanField(default=False)
tags = TaggableManager()
tags = TaggableManager(blank=True)
class Meta:
verbose_name = _("Article")
......
......@@ -83,7 +83,7 @@ class ArticleEdit(UpdateView):
# Change the layout of the tags field
form.fields["tags"] = TagMultipleChoiceField(
queryset=Tag.objects.all())
queryset=Tag.objects.all(), required=False)
left_layout = Div(
Div(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment