Django第一个应用程序[重复]

Posted

技术标签:

【中文标题】Django第一个应用程序[重复]【英文标题】:Django First Aplication [duplicate] 【发布时间】:2020-12-09 19:51:33 【问题描述】:

启动python manage.py run server后抛出这样的错误,在创建目录之前,server页面启动正常。

M:\Project_Django\mysite>python manage.py runserver 正在执行系统检查...

Unhandled exception in thread started by <function wrapper at 0x043E18F0>
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Python27\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 256, in check
    for pattern in self.url_patterns:
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 407, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 400, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "M:\Project_Django\mysite\mysite\urls.py", line 17, in <module>
    from django.urls import path, include,strona
ImportError: cannot import name path

【问题讨论】:

***.com/questions/47563013/… 【参考方案1】:

支持 python 2.7 的最后一个版本是 django 1.11,它没有新的路径语法,请查看适当的文档。如果您刚开始使用 python 3.*,还可以考虑更新您的 Django 版本

【讨论】:

以上是关于Django第一个应用程序[重复]的主要内容,如果未能解决你的问题,请参考以下文章

Django学习路30_view中存在重复名时,取第一个满足条件的

将Django模型从一个应用程序移动到另一个[重复]

如何在django admin中对不存在的字段进行排序/排序[重复]

Django admin list_filter 重复

Django - 使用给定的 sql 转储创建其他模型并填充数据 [重复]

django的url分发封装