简体   繁体   English

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

[英]Django is not able to run manage.py runserver how to solve?

I'm trying to run manage.py server but it hit some error!我正在尝试运行 manage.py 服务器,但遇到了一些错误! I've just trying to print hello in web but it insn't working我只是想在网络上打印 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.

If you want any .py file feel free to ask thank you!如果您想要任何 .py 文件,请随时询问谢谢! My project Dir : https://github.com/shreekantbatale2/Oinn我的项目目录: https : //github.com/shreekantbatale2/Oinn

In your repo 在您的仓库中
Make following changes: 进行以下更改:
In openin/urls.py file: 在openin / urls.py文件中:
You have misspelled urlpatterns (You coded urlPatterns) urlpatterns拼写错误(您对urlPatterns进行了编码)
In file Oin/urls.py 在文件Oin / urls.py中
path('^$', include('openin.urls')),
to
path('', include('openin.urls')),

It looks like you need either one of these two options in your urls.py file: 看起来您需要在urls.py文件中使用以下两个选项之一:

from django.urls import path

from . import views

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

Or if you're using the url dispatcher, more likely given what is in your urls.py file : 或者,如果您使用的是url分配器, 则更可能使用urls.py文件中的内容

from django.conf.urls import url

from . import views

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

wrapper fn(*args, **kwargs) File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\commands\\runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\base.py", line 419, in check all_issues = checks.run_checks( File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\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\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\urls.py", line 40, in check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\urls.py", line 67, in _load_all_namespaces namespaces.extend(_load_all_namespaces(pattern, current)) File "C:\\Users\\91639\\AppData\\Local包装器 fn(*args, **kwargs) 文件“C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\commands\\runserver.py”,第 118 行, 在 inner_run self.check(display_num_errors=True) 文件“C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\management\\base.py”,第 419 行,在 check all_issues = checks.run_checks( File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\registry.py",第 76 行,在 run_checks new_errors = check(app_configs=app_configs, databases=databases) 文件“C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\urls.py”,第 40 行,在 check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) 文件“C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\urls.py”中,第 67 行,在 _load_all_namespaces 命名空间中.extend(_load_all_namespaces(pattern, current)) 文件“C:\\Users\\91639\\AppData\\Local \\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\urls.py", line 57, in _load_all_namespaces url_patterns = getattr(resolver, 'url_patterns', []) File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\utils\\functional.py", line 48, in get res = instance. \\Programs\\Python\\Python39\\lib\\site-packages\\django\\core\\checks\\urls.py”,第 57 行,在 _load_all_namespaces url_patterns = getattr(resolver, 'url_patterns', []) 文件“C:\\Users\\91639 \\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\utils\\functional.py”,第 48 行,在get res = instance. dict [self.name] = self.func(instance) File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\urls\\resolvers.py", line 607, in url_patterns raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'hello.urls' from 'C:\\Users\\91639\\squadmate\\hello\\urls.py'>' does not appear to have any patterns in it. dict [self.name] = self.func(instance) File "C:\\Users\\91639\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\django\\urls\\resolvers.py",第 607 行,在 url_patterns 中从 e django.core.exceptions.ImproperlyConfigured 中引发 ImproperlyConfigured(msg.format(name=self.urlconf_name)):包含的 URLconf '<module 'hello.urls' from 'C:\\Users\\91639\\squadmate\\hello\\ urls.py'>' 中似乎没有任何模式。 If you see valid patterns in the file then the issue is probably caused by a circular import.如果您在文件中看到有效模式,则问题可能是由循环导入引起的。

Blockquote I am trying to run python manage.py runserver for Django but this bug is there. Blockquote 我正在尝试为 Django 运行 python manage.py runserver 但这个错误在那里。 somebody, please help me.有人,请帮助我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM