Issue
I have the newest PyCharm version (2018) and the latest Django version (2.1) and Python (3.6)
When I want to import something in PyCharm from Django:
from django.urls import url
I get an error message under django stating: Unresolved reference 'django'
I created a virtual environment and I ran a project on it, the most famous one (polls) and it ran very well.
But now I noticed that I have this error, what is the solution?
Thank you in advance.
Solution
The current virtual environment you are using does not have django installed in it. Installing it for the current environment or using a project interpreter which have django installed should resolve the issue.
1. Installing Django on your current virtual environment via pycharm settings.
- Go to Settings > Project > Project Interpreter and click the green plus sign on the right hand side (install option).
- Search for django in the search bar of the available packages dialog and select it.
- Select the install package option at the bottom.
2. Installing Django on your current virtual environment via pycharm terminal.
Click on the pycharm terminal and install django using
pip install Django
3. Changing the current project Interpreter.
Go to Settings > Project > Project Interpreter and click on the project interpreter drop down menu.
Choose a project interpreter which have django installed.
Answered By - Nipun Sampath