[Solved]-Python: ImportError: No module named 'tutorial.quickstart'

16👍

Change from tutorial.quickstart import views to from quickstart import views in both tutorial/url.py file as well as tutorial/quickstart/views.pyfile. This should work.

This is required as python automatically adds your current directory to sys path.

6👍

Just change tutorial.quickstart import views to from quickstart import views in both tutorial/url.py file as well as tutorial/quickstart/views.py file.

4👍

USE:

django-admin startproject tutorial .

INSTEAD of:

django-admin startproject tutorial

while you start the project.

It is mentioned in the documentation.(Read carefully)

1👍

Make sure your tutorial.quickstart is in the same folder as your project.
Also make sure it is unzipped ! Otherwise use a absolute path.

Hope it helps !

👤M.Koch

1👍

You should use from quickstart import views instead of from tutorial.quickstart import views if you use PyCharm or other IDE. And don’t forget change code where use from tutorial.quickstart.[xxx] import [xxx].

1👍

In quickstart/views.py:
from .serializers import UserSerializer, GroupSerializer
in tutorial/urls.py:

from quickstart import views

That worked for me.

1👍

It works for me by modification tow importing files

  • /tutorial/quickstart/views.py

from tutorial.quickstart.serializers import UserSerializer, GroupSerializer

to

from quickstart.serializers import UserSerializer, GroupSerializer

  • /tutorial/urls.py

from tutorial.quickstart import views

to

from quickstart import views

0👍

i was getting this issues several times,

with-

python version3.6.9

django version3.2.14 and

restframework3.13.1

so, first step:

i just updated the python version to 3.9.13 and django version to 4.0.6 and restframework version was same as before.

second step:

Change from tutorial.quickstart import views to from quickstart import views in tutorial/urls.py file

as well as if you write

from serializers import UserSerializer, GroupSerializer

or

from tutorials.quickstart.serializers import UserSerializer, GroupSerializer

in tutorial/quickstart/views.py file then you can change it to

from quickstart.serializers import UserSerializer, GroupSerializer or from .serializers import UserSerializer, GroupSerializer.

Hopefully, This should work.

👤nuuks

Leave a comment