Hi there – I've been using PyCharm for a while without any issues, but today I'm running into unresolved reference errors for django in my all my files and I can't figure out why.
- I'm using a virtualenv
- The application launches and runs without any errors
- PyCharm is popping up the "package requirements are not satisfied" message when I first open the project (and one of the requirements it's saying isn't satisfied is Django), but the requirements are definitely installed, and when I go to the settings screen for the project in PyCharm to install them, it shows them as installed.
I'm starting to think it might be an issue with how I have the project set up, either the directory structure or maybe the fact that I'm using multiple settings files.
As far as the directory structure goes, I have a top-level directory that is my git repo root. Within that I have requirements.txt. Then inside that directory (i.e. a directory at the same level as requirements.txt) I have the root of the Django project – here's the high-level layout:
This is the project layout proposed in Two Scoops of Django if you're familiar with that book.
As far as how I fired this up as a project in PyCharm, I did File -> Open Directory and pointed to the root of the git repo as opposed to the root of the Django app itself.
So my first question is, and this may be at the heart of the unresolved reference error, why is PyCharm insisting that I don't have my package requirements satisfied when I do? Would that cause the unresolved reference errors? Do I need to move my requirements.txt file elsewhere, or is there a way to point PyCharm directly to it?
My second question is if this is related to the fact that I'm using multiple settings files? Each of the environment-specific settings files imports everything from the base file (from .base import *). In the PyCharm Python interpreter settings for this project I added –settings=foo.settings.local in the Additional options box. And when I launch the app from PyCharm, it very clearly says "Django version 1.5.1, using settings 'foo.settings.local'" in the console.
Note that I have not
run into this issue in projects with the requirements.txt file in the same directory as manage.py and in which I use a single settings.py file, but before giving up on what I think is a much better project structure I figured I better ask what might be going on here.
Happy to provide more information to help troubleshoot. Thanks in advance for any ideas people might have.