I'm developing a simple api rest With Django 2.2.1, djangorestframework and Python 3, but I'm stuck when try to run 'makemigrations' command, receiving the following message:

return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'clients.urls'

My project folder structure is the following:

./api
./api/settings.py
./api/urls.py
./api/wsgi.py
./api/__init__.py
./api/__pycache__
./api/__pycache__/settings.cpython-37.pyc
./api/__pycache__/urls.cpython-37.pyc
./api/__pycache__/__init__.cpython-37.pyc
./clients
./clients/admin.py
./clients/apps.py
./clients/models.py
./clients/tests.py
./clients/views.py
./clients/__init__.py
./clients/__pycache__
./clients/__pycache__/admin.cpython-37.pyc
./clients/__pycache__/models.cpython-37.pyc
./clients/__pycache__/__init__.cpython-37.pyc
./db.sqlite3
./manage.py

I've tried to import clients in urls.py and settings.py and nothing changed. I need to get this project done for a interview test but I'm stuck in this that looks like a silly detail that I'm not seeing. I hope some of you can help me see whats is wrong with my code and what is the pattern when generating the project and app. Is the folder structure above correct for a django rest api project?

My urls.py:

from django.contrib import admin
from django.urls import path, include
#import clients I've tried this with no success

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('clients.urls'))
]

1 Answers

2
Anjaneyulu Batta On Best Solutions

You have no module clients/urls.py that's the reason it's showing the error ModuleNotFoundError: No module named 'clients.urls'.

Create file clients/urls.py then it will work.