1. 程式人生 > 其它 >用django-tinymce報錯

用django-tinymce報錯

Traceback (most recent call last):
File "D:\pythonproject\manage.py", line 22, in <module>
main()
File "D:\pythonproject\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 420, in execute
django.setup()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 116, in populate
app_config.import_models()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "D:\pythonproject\book\models.py", line 2, in <module>
from tinymce.models import HTMLField
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\tinymce\models.py", line 6, in <module>
from tinymce import widgets as tinymce_widgets
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\tinymce\widgets.py", line 17, in <module>
from django.utils.encoding import force_text
ImportError: cannot import name 'force_text' from 'django.utils.encoding' (C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\encoding.py)

更新版本
D:\pythonproject>pip install --upgrade django-tinymce
Requirement already satisfied: django-tinymce in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (2.6.0)
Collecting django-tinymce
Downloading django_tinymce-3.4.0-py3-none-any.whl (1.1 MB)
|████████████████████████████████| 1.1 MB 469 kB/s
Installing collected packages: django-tinymce
Attempting uninstall: django-tinymce
Found existing installation: django-tinymce 2.6.0
Uninstalling django-tinymce-2.6.0:
Successfully uninstalled django-tinymce-2.6.0
Successfully installed django-tinymce-3.4.0
WARNING: You are using pip version 21.2.4; however, version 22.0.3 is available.
You should consider upgrading via the 'C:\Users\Administrator\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.


D:\pythonproject>python manage.py makemigrations
Migrations for 'book':
book\migrations\0002_alter_test_detail.py
- Alter field detail on test