Fix Circular Import in Django

In some rare cases, you may import a file that imports the file you are importing from. This may seem a bit recursive, and it is. In Python, this is called a circular import error.

The best way to recognize a circular import gone wrong is to look at your results. You’ll get an ImportError message from Django, like cannot import some_view from your_project.views. When you look in your_project/, you see that some_view actually exists in that same file. Right? That wasn’t planned.

Don’t miss these tips!

We don’t spam! Read our privacy policy for more info.

Open chat
Powered by