1
resposta

ModuleNotFoundError: No module named 'receitas.urls'

Boa tarde!

Quando tento rodar a para acessar o site no meu browser com o código python manage.py runserver.

Ele me retorna o erro


Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper     
    fn(*args, **kwargs)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\core\management\base.py", line 487, in check  
    all_issues = checks.run_checks(
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    return check_method()
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\urls\resolvers.py", line 480, in check        
    for pattern in self.url_patterns:
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__     
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\urls\resolvers.py", line 696, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__     
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\urls\resolvers.py", line 689, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\alurareceitas\urls.py", line 20, in <module>
    path('', include('receitas.urls')),
  File "C:\Users\Duda Laclaw\Desktop\aplicacao\venv\lib\site-packages\django\urls\conf.py", line 38, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'receitas.urls'`

Mas o 'receitas.urls', está declarada como parâmetro do include na pasta de urls.py.

1 resposta

Oi! Pelo o que eu entedi do erro é que o Django não está achando o arquivo urls.py do app receitas. Neste caso é só criar um arquivo urls.py dentro da pasta receitas.