11
votes

After having an unexpected shutdown on my DEV machine, when going back to Pycharm project, I noticed the Django view file I was editing (which had 700+ lines) when that happened, it was completely empty. I managed to restore it from a backup; no loss there.

The problem comes up when trying to debug, it returns this error: "ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings." Process finished with exit code 137

The Pycharm settings Django Support (project root, settings & manage script) have the expected values as well.

If I run the project with the ./manage .py runserver command, everything is fine. I can even access the DB with manage.py dbshell. I looked at my settings file and everything seems OK. I also updated from version 3.0.1 to 3.1.1, and no difference.

I'm using Django 1.6.1 and postgresql 9.2.7. What can I do?

1
How about removing the .idea directory and creating a new project from this directory. This would cause it to rebuild indexes. - PhoebeB
So, if I understand correctly, the .idea directory is what Pycharm looks for, when identifying configured projects and show it in the 'Recent Projects' list to choose from. On the other hand, since I'm using GIT, and there is (hidden) .git directory, if re-create the project within Pycharm, would I still be able to do the GIT pull/push (in VCS menu) as usual? - Rmartin

1 Answers

18
votes

For Pycharm, just go to Run -> Edit Configurations, select your project on the right of the window from Debug Configuration, and you will see Environment variables on the right. Make sure you have set DJANGO_SETTINGS_MODULE=mysite.settings, if not just add one, it is as easy as fill a key value pair from the pop up dialog.