Technology

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/views.py, you see that some_view actually exists in that same file. Right? That wasn’t planned.

close

Don’t miss these tips!

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

No products in the cart.

Open chat
Powered by