Taggit doesn't seem to save tags on model creation.

452 views
Skip to first unread message

Anthony Roberts

unread,
Jul 8, 2013, 8:53:24 AM7/8/13
to django...@googlegroups.com
Maybe I'm not using it correctly, but when I create a new instance of a model with a tags field, it doesn't save the tags on creation.

I'm creation articles, and adding tags, like so:

models.py:

class Article(models.Model):    
    title = models.CharField(max_length=100, verbose_name="Headline")
    slug = models.SlugField(max_length=100, unique=True)
    text = models.CharField(max_length=10000)
    # etc.
    tags = TaggableManager(blank=True)

    def __unicode__(self):
        return self.title

views.py:

def add_article(request):
    if request.method == 'POST':
        form = ArticleForm(request.POST, request.FILES or None)
        if form.is_valid():
            article = form.save(commit=False)
            article.author = request.user
            article.save()
            msg = "Article saved successfully"
            messages.success(request, msg, fail_silently=True)
            return redirect(article)
    else:
        form = ArticleForm()
    return render_to_response('story/article_form.html', 
                                           { 'form': form },
                                           context_instance=RequestContext(request))

Thank you.


Florian Apolloner

unread,
Jul 8, 2013, 10:24:23 AM7/8/13
to django...@googlegroups.com

alinou...@gmail.com

unread,
Jul 30, 2017, 8:03:42 AM7/30/17
to django-taggit
I am currently having the same problem. Would appreciate an update.

I have looked at the link posted by Florian Apolloner. It didn't help me.
Reply all
Reply to author
Forward
0 new messages