I am writing custom template tag, and the error occurs that "Unresolved reference 'models'" the following is my blog_tags.py.
from django import template
from .models import Post
register = template.Library()
@register.simple_tag
def total_posts():
return Post.published.count()
And my directory tree is as followed
blog/
__init__.py
models.py
...
templatetags/
__init__.py
blog_tags.py
And i do have a Post class in my Models.
And when i click the prompt by pycharm "install package Post", after finishing installed it, the error disappear. I wonder do i have to do the same, which is install the package by the IDE, every time when i want to write a custom tag evolved with class in my Models?