python - 我的开发服务器运行后报这个错误
问题描述
我的django项目运行开发服务器后报错:
每次运行开发服务器时都会出现此错误:
在运行服务器之前已激活虚拟环境。如何解决它并让我的项目再次运行?
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "c:\users\bello\anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "c:\users\bello\anaconda3\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "c:\users\bello\anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\bello\Desktop\DESKTOP\EDX\mosque-around-you\mosque-around-you\mosquesinlocation\models.py", line 3, in <module>
from cities_light.models import City, Region as State, Country
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\cities_light\models.py", line 83, in <module>
from .abstract_models import (AbstractCountry, AbstractRegion,
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\cities_light\abstract_models.py", line 5, in <module>
import autoslug
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\autoslug\__init__.py", line 11, in <module>
from autoslug.fields import AutoSlugField
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\autoslug\fields.py", line 29, in <module>
from autoslug.settings import slugify, autoslug_modeltranslation_enable
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\autoslug\settings.py", line 68, in <module>
slugify = get_callable(slugify_function_path)
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\django\urls\utils.py", line 28, in get_callable
mod = import_module(mod_name)
File "c:\users\bello\anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\bello\Envs\mosque-around-you\lib\site-packages\autoslug\utils.py", line 15, in <module>
from django.db.models.fields import FieldDoesNotExist, DateField
ImportError: cannot import name 'FieldDoesNotExist'
解决方案
您必须django-autoslug
从一个版本更新<= 1.9.7
到另一个版本,1.9.8
因为 Django3.1
删除了FieldDoesNotExist
重新导入django.db.models.fields
如记录的
删除了 django.db.models.fields 中 django.core.exceptions.FieldDoesNotExist 的兼容性导入。
推荐阅读
- php - 如果只定义了这行代码代码,它是如何执行的?
- karate - 空手道:获取所有用户并使用参考 id 删除
- javascript - 将 nl2br 移植到 Javascript/React - 如何手动转义文本?
- c# - 动态计算队列中的等待时间
- python - 根据列约束生成列
- printing - iOS 13 AirPrint 问题:可以打印一次到 UIPrinter,随后出现控制台错误,例如 Print-Job failed: Printer not found
- c# - " "这里不允许,因为它没有扩展类 'System.Web.UI.Page'
- json - 在 IE 中将 JSON 显示为 HTML 而无需下载
- html - 我无法通过打开 HTML 文件看到我的 D3.js 设计
- sql - 多张同形桌子的ERD设计