I'm trying to import:
from django.db import models
PyCharm underlines django.db
and complains: Unresolved reference 'django'
.
How do I get PyCharm to recognize Django?
To enable Django support, follow these steps: Open the project Settings/Preferences dialog ( Ctrl+Alt+S ) and navigate to the Languages & Frameworks | Django page. Make sure that the checkbox Enable Django support is selected. Apply changes (if any) and close the dialog.
Sure, it is quite possible to run the Django server, then go to your browser, and type the entire URL in the address bar, but with PyCharm there is an easier way: use the pre-configured Django server run configuration with some slight modifications.
I assume you're using a virtualenv which is located in the same directory as other project files. Python should know exactly that path. So, it's possibly that Pycharm is using the wrong Interpreter.
Go to Settings -> Project: -> Project Interpreter -> switch to the right path
In the interpreter packages, there should be Django package installed. If not, do it here/in terminal.
Mark root folder of project as 'Sources root', it works for me. Content Root
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With