运行Django应用程序时出错

carvr3hs  于 2023-08-08  发布在  Go
关注(0)|答案(1)|浏览(115)

我正在学习通过django框架部署机器学习模型的教程。这是教程Link1的链接,我正确地遵循了所有步骤,直到第3步。首先,我自己写了所有的代码。看到我的应用程序不起作用,我从网站上复制并粘贴了所有Django代码。这是我在gitHub Link2上的项目的链接
我使用python 3.6django==2.2.4
当我在终端中运行python manage.py runserver时,我得到以下错误消息:

(venv) C:\Users\SEYDOU GORO\my_ml_service2\backend\server>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\urls\resolvers.py", line 604, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\SEYDOU GORO\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\SEYDOU GORO\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\core\management\base.py", line 423, in check
    databases=databases,
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\urls\resolvers.py", line 416, in check
    for pattern in self.url_patterns:
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\SEYDOU GORO\my_ml_service2\venv\lib\site-packages\django\urls\resolvers.py", line 611, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf 'server.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

字符串
我不知道发生了什么事,但我需要帮助来了解发生了什么事。

wd2eg0qa

wd2eg0qa1#

Django Documentation: URL dispatcher中有关于如何包含其他URLconf的示例。

from django.urls import include, path

urlpatterns = [
    # ... snip ...
    path('community/', include('aggregator.urls')),
    path('contact/', include('contact.urls')),
    # ... snip ...
]

字符串
您在backend/server/server/urls.py中遗漏了include(),这将导致错误The included URLconf 'server.urls' does not appear to have any patterns in it.

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


看到区别了吗?

相关问题