小问题

Django实战教程

在Python3的环境下,可能报·python_2_unicode_compatible·错误

需要将代码替换以下

1
from django.utils.encoding import python_2_unicode_compatible
1
from six import python_2_unicode_compatible

也运行以下代码即可

1
2
3
4
5
6
7
8
#!/bin/sh
sed -i 's#from django.utils.encoding import python_2_unicode_compatible#from six import python_2_unicode_compatible#' /usr/local/lib/python3.7/site-packages/aldryn_categories/models.py &&
sed -i 's#from django.utils.encoding import force_text, python_2_unicode_compatible#from django.utils.encoding import force_text#' /usr/local/lib/python3.7/site-packages/aldryn_newsblog/models.py &&
sed -i '/from django.utils.encoding import force_text/afrom six import python_2_unicode_compatible' /usr/local/lib/python3.7/site-packages/aldryn_newsblog/models.py &&
sed -i 's#from six import python_2_unicode_compatible/#from six import python_2_unicode_compatible#' /usr/local/lib/python3.7/site-packages/aldryn_newsblog/models.py &&
sed -i 's#from django.utils.encoding import force_text, python_2_unicode_compatible#from django.utils.encoding import force_text#' /usr/local/lib/python3.7/site-packages/aldryn_people/models.py &&
sed -i '/from django.utils.encoding import force_text/afrom six import python_2_unicode_compatible' /usr/local/lib/python3.7/site-packages/aldryn_people/models.py &&
sed -i 's#from django.utils.encoding import python_2_unicode_compatible#from six import python_2_unicode_compatible#' /usr/local/lib/python3.7/site-packages/aldryn_newsblog/cms_appconfig.py

📚 返回目录

本文作者:Samjoe Yang

本文链接: https://need.uno/django-course-xiao-wen-ti/

版权声明:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。

评论