Import "taggit.managers" could not be resolved

Im currently learning django with the book "Django 2" by Antonio Melé. I got an error when I import "from taggit.managers import TaggableManager". I already install django-taggit and django-extensions. I also already added 'taggit' to INSTALLED_APPS. Here is my


My (There are more classes but I put the one that im working on):

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.urls import reverse
from taggit.managers import TaggableManager

class Post (models.Model):
    ('draft', 'Draft'),
    ('published', 'Published'),

title = models.CharField(max_length=150)
slug = models.SlugField(max_length=250, unique_for_date='publish')

author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts')

body = models.TextField()

publish = models.DateTimeField(

created = models.DateTimeField(auto_now_add=True)

updated = models.DateTimeField(auto_now=True)

status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='published')

class Meta:
    ordering = ('-publish',)

def __str__(self):
    return self.title

objects = models.Manager()
published = PublishedManager()

def get_absolute_url(self):
    return reverse('blog:post_detail', args=[self.publish.year, self.publish.month,, self.slug])

tags = TaggableManager()

Image of the error, just in case

I ran python shell and after the following:

from blog.models import Post
post = Post.objects.get(id=1)
post.tag.add('post1', 'blogpost', 'tag1')

And the tags were added successfuly.

It seems your indentation in the is the issue

Restart your python server then run the initial migration

Back to Top