"importerror: No Module Named Urls" While Following Django Tutorial
Solution 1:
That tutorial requires Django 1.10 while you seem to be using an older version. In this case, you should import reverse
as follows:
from django.core.urlresolversimport reverse
To upgrade your Django version, use the following command (in your command line, not in the Python shell):
pip install --upgrade django
Solution 2:
Latest tutorial (https://docs.djangoproject.com/en/2.0/intro/tutorial01/) uses Django 2.0, which supports Python 3.4 and later
Since I ran into this same issue I had to upgrade by python as well as django
sudo apt-get-y install python3-pip
pip3 install --upgrade django
to see your django version run following command -
python3 -c "import django; print(django.get_version())"
for me it says 2.0.1
To check python version run -
python3 --version
For me it is Python 3.5.2
Solution 3:
At times, if one has multiple copies of django running on one's machine like I had, if the current project requires a different version of sjango, it is easier to simply go to preferences -> project interpreter -> add a virtual env -> install latest copy of django
.
Now pycharm will interpret the project correctly.
Post a Comment for ""importerror: No Module Named Urls" While Following Django Tutorial"