OperationalError 1054 Unknown column 'tags' using django-tagging

486 views Asked by At

I'm trying to use django-tagging in my django app, but I'm getting an SQL error when inserting the field

my model has tags = TagField()

>>> from cms.models import Articles
>>> a=Articles()
>>> a.save()
OperationalError: (1054, "Unknown column 'tags' in 'field list'")

Do I need a "tags" text field on my DB? AFAIK django-tagging just handles that with its tables (tagging_tag and tagging_taggeditem)

thanks

1

There are 1 answers

0
César On

Did you try manage.py syncdb? I recommend using the tagging.register instead of declaring a "tags" field in your model:

models.py:

import tagging

class Articles(models.Model):
    ...

tagging.register(Articles)

forms.py:

from tagging.forms import TagField

class ArticlesForm(ModelForm):
    tags = TagField()

    def save(self, commit=True):
        instance = super(ArticlesForm, self).save(commit)
        instance.tags = self.cleaned_data['tags']
        return instance

    class Meta:
        model = Articles