Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-taggit: make the tags not required in the admin

I've started using django-taggit and it seems to fit the bill. But for me there is still an issue with the admin site:

I included the tags attribute in the ModelAdmin like this:

class MyModel(db.models.Model):
    name = models.CharField(max_length=200)
    tags = TaggableManager()

class MyModelAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {
            'fields': ('name', 'tags')
        }),
    )

And everything goes as expected. But when I edit a model in the admin, I get an error, if the TagField is empty. The form seems to be happy with just a blank, and that results in no tags being saved (as expected). But an empty tag field triggers the error.

What can I do?

like image 962
jammon Avatar asked Jun 12 '11 07:06

jammon


1 Answers

Did you try tags = TaggableManager(blank=True)?

blank – Controls whether this field is required

... at least that's what the docs say.

like image 82
arie Avatar answered Oct 18 '22 05:10

arie