Python 没有名为django.shortcuts的模块
我正在创建一个Django项目,但遇到了一个问题。在my views.py文件中,Ubuntu上的Wing IDE调试器显示:Python 没有名为django.shortcuts的模块,python,django,Python,Django,我正在创建一个Django项目,但遇到了一个问题。在my views.py文件中,Ubuntu上的Wing IDE调试器显示: File "/home/deanna/django_test/article/views.py", line 1, in <module> from django.shortcuts import render_to_response ImportError: No module named django.shortcuts 当我在本地主机上运行该网页时
File "/home/deanna/django_test/article/views.py", line 1, in <module>
from django.shortcuts import render_to_response
ImportError: No module named django.shortcuts
当我在本地主机上运行该网页时,会出现以下错误:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/articles/all/
Using the URLconf defined in django_test.urls, Django tried these URL patterns, in this order:
^all/$
^get/(?P<article_id>\d+)/$
^language/(?P<language>[a-z\-]+)/$
The current URL, articles/all/, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
我将django.shortcuts下载到我的django_测试文件中,但我不知道为什么调试器会抱怨,或者为什么我的网页没有加载。谢谢。当您面对这些类型的错误时:
ModuleNotFoundError: No module named 'django.shortscuts'
首先检查拼写是否正确:
from django.http import HttpResponse
from django.shortcuts import redirect
在第二个错误中,您的/articles/all/path似乎未在url.py上定义,请创建一个类似于^articles/all/$的路径您的应用程序中是否有名为django的文件或包?最有可能的情况是覆盖默认的django如果您使用的是虚拟环境,您是否在IDE的设置中启用了它?“我将django.shortcuts下载到我的django_测试文件中”。为什么?如中所示,为什么不直接安装Django本身;然后它会自己找到
django.shortcuts
。现在,您可能需要类似于从快捷方式导入的。
或甚至从django\u test.shortcuts导入的。
。您应该使用默认的django快捷方式。您不应该明确下载任何内容。
ModuleNotFoundError: No module named 'django.shortscuts'
from django.http import HttpResponse
from django.shortcuts import redirect