python - 我有一个关于运行 python manage.py test 的命令行的 Django 问题
问题描述
当我在命令行上以绝对路径名 C:\Users\vitorfs\Development\myproject\myproject 运行命令 python manage.py test 时出现此错误,我通过在 Windows 上选择 Run as Admin 打开该命令行。在boards.py中,我有以下
from django.core.urlresolvers import reverse
from django.test import TestCase
class HomeTests(TestCase):
def test_home_view_status_code(self):
url = reverse('home')
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
这是我得到的错误:
1. Failed to import test module: board.tests. 2. ModuleNotFoundError: No module named django.core.urls
我无法修复错误。我在https://simpleisbetterthancomplex.com/series/2017/09/11/a-complete-beginners-guide-to-django-part-2.html遵循了关于 Django 的教程
你能告诉我这意味着什么并帮助我解决这个错误吗?
只是为了让你知道,我学习 Python 和 Django 是为了好玩。
解决方案
重新安装 django 是唯一的选择,因为您的core
实用程序已损坏
按着这些次序:
在您的命令提示符中-
在您的命令提示符中- # 假设您使用 django 2.7pip uninstall django
pip install django==2.7
推荐阅读
- c# - 我在将数据从 XML 文件移动到具有 CDATA 节点类型的 ARRAY 时遇到问题
- reactjs - 将快递与护照整合在一起的麻烦
- python - How to concatenate tensor to another list of tensor in pytorch?
- android - 不允许用户添加相同的命名子 Firebase Android?
- keycloak - 如何限制添加到 keycloak 领域的用户数量?
- c# - 使用带有常量传入 byteArray 的 MixingSampleProvider
- ajax - a4j:支持在ajax调用jsf后清空selectOneMenu字段
- python - 按值传递递归?
- sql-server-2014 - 销售 SQL 的 MTD 和 YTD
- r - 如何使用 R 在合并中的两个观察中使用来自一个观察的数据?