简体   繁体   中英

Can't save tags in admin using django-taggit

I am using django-taggit and I can't save the tags when creating a new post from the admin panel, when I edit a post I had already created before adding django-taggit, it saves the tags well, what might be the problem?

Models.py

class BlogPost(models.Model):
    title = models.CharField(max_length=200, unique=True)
    slug = models.SlugField(max_length=200, unique=True)
    author = models.ForeignKey(
        User, on_delete=models.CASCADE, related_name='blog_posts')
    description = models.CharField(max_length=500)
    content = RichTextUploadingField(config_name='awesome_ckeditor')
    tags = TaggableManager()
    category = models.ForeignKey(
        'Category', related_name='category', on_delete=models.CASCADE)
    cover = models.ImageField(upload_to='images/')
    created_on = models.DateTimeField(auto_now_add=True)
    updated_on = models.DateTimeField(auto_now=True)
    #read_time = models.TimeField(null=True, blank=True)
    status = models.IntegerField(choices=STATUS, default=0)
    series = models.IntegerField(choices=SERIES, default=0)

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse("blog:detail", args=[str(self.slug)])

Do you receive any error during saving post? Did you make python manage.py migrate after installing django-taggit and include it to INSTALLED_APPS ? You have made change in the model so you need to prepare your db to work with new data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM