[Answered ]-Why can't I import a function from views into a model in django?

2👍

You have a circular import issue. Your models file has a views import, then your views import has a model import. There are a number of ways to solve this, we’d have to see your models and views source.

0👍

I know this thread is really old, but just in case it might help someone else, I wanted to share how I fixed this when I had this same problem. As @professorDante has said it is a circular import issue, and so I was able to simply create another file, which I called shared_functions.py and move the function, test(), into that file. Then I could import the function in to both of my files that previously had the circular import issue as:

from .shared_functions import test

Leave a comment