Django app in Eclipse will not start after upgrading to django 1.4

After migrating to Django 1.4, I get the following error message:

raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named py 

I read that this might have something to do with pydev 2.4, for example: here , so I updated pydev to the latest version, 2.5. I am using eclipse indigo.

I started to look at the running work and noticed that the django 1.3 egg is still referenced. Therefore, I switched to windows / preferences / pydev / interpreter-python, and in the 1.3th pit was mentioned in the path of the PYTHON system.

To fix this, I removed the existing python interpreter and added a new one again. My python starts from venv, so I added this. An error has occurred:

Error message

I don't think this is related, but I see that / venv / lib appears in the System PYTHONPATH list, whereas on Windows the folder is called / venv / Lib, so I added it as well. However, the new django egg was not included, so I manually added it to the Libraries window.

However, I still get the error message.

The application works fine from the command line.

+6
source share
4 answers

I thought about it a few hours later, trying all sorts of things.

I created a new Django project using pydev 2.5 to see what happens, and I noticed that the entry "django settings module" (see below) was appname.settings. I used to set 'settings.py'. I completely deleted the entry that cleared the first issue.

enter image description here

After that, I got a "module appname not found" error, so I tried putting the empty __init__.py file in the root of my application, which seemed to work.

+5
source

In virtualenv, this usually happens when you forget to add / Lib from the python base installation during the installation process (therefore, when searching in PYTHONPATH it does not find things like "threading.py" or "threading.py", traceback.py ', etc. .d.

+1
source

I solved this by adding the following to manage.py :

 import os os.environ['DJANGO_SETTINGS_MODULE'] = '<django_app_folder>.settings' os.environ['SERVER_NAME'] = '<name_of_server>' 

<django_app_folder> is the name of the folder containing the settings.py file.

<name_of_server> should be there, but I did not find what matters, what it is installed on.

0
source

I had this problem. My project did not have the PyDev-Django property, so another solution did not work here. I think this is because I did not initially create it as a Django project. Instead it worked:

  • right-click project> properties> PyDev PYTHONPATH> string substitution variables.
  • Add a variable named DJANGO_SETTINGS_MODULE. Its value should be the value of yourapp.settings (or edit it if it already exists).
0
source

Source: https://habr.com/ru/post/913781/


All Articles