Pycharm insists on running one of the project scripts with every Django command // Sloppy Development 🤭

I am starting the Careless Development series where I post a little issue that started as a problem solving and ended up being an oversight issue. Utter disappointment! It took me some time to inspect Pycharm inside and out, so here it is.

I should say that the bigger the project, the more it happens. But enough of self-justification.

So I needed to test a script that uses Django, so in Pycharm manage.py console I ran this command:

shell < proj/extras/text.py

Of course, it contained numerous prints to test results…

At some point, I was satisfied with the results and I decided to import it somewhere in my project’s apps’ models. I didn’t use it right away, so I didn’t remember importing it at all.

Of course. I didn’t remove prints…

Eventually, the reason why ‘Pycharm insisted on running the script‘ was that before running a command Django runs everything Django-related the project contains, including imports…

Simply amazing.

Though, you can use Ctrl + Shift + O to remove unused imports, but it can bring you more trouble than help.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.