gpt4 book ai didi

python - Django无法运行manage.py runserver如何解决?

转载 作者:行者123 更新时间:2023-12-01 01:39:43 42 4
gpt4 key购买 nike

我正在尝试运行manage.py服务器,但它遇到了一些错误!我只是想在网络中打印 hello,但它不起作用

(venv) ubuntu@node:~/PycharmProjects/Oin$ python manage.py runserver
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fd985430158>
Traceback (most recent call last):
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 542, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check(display_num_errors=True)
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 400, in check
warnings.extend(check_resolver(pattern))
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 399, in check
for pattern in self.url_patterns:
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 549, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'openin.urls' from '/home/ubuntu/PycharmProjects/Oin/openin/urls.py'>' 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.

如果您想要任何 .py 文件,请随时询问谢谢你!我的项目目录:https://github.com/shreekantbatale2/Oinn

最佳答案

看起来您需要在 urls.py 文件中选择以下两个选项之一:

from django.urls import path

from . import views

urlpatterns = [
path('', views.index, name='home')
]

或者,如果您使用 url 调度程序,根据您的 urls.py 文件中的内容,更有可能强>:

from django.conf.urls import url

from . import views

urlpatterns = [
url(r'^', views.index, name='home')
]

关于python - Django无法运行manage.py runserver如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52018196/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com