今天搭建
Ubuntu_64_catmaid_4
运行
./manage.py runserver
出现 no name force_text的错误
修改文件
/home/hhb/work/catmaid_5d_visualization_annotation/django/env/lib/python2.7/site-packages/django/utils/encoding.py
添加内容
187 # Forwords compatibillity with Django 1.5
188 # Added by Haibo Hao
189 def python_2_unicode_compatible(klass):
190 # Always use the Python 2 branch of the decorator here in Django 1.4
191 klass.__unicode__ = klass.__str__
192 klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
193 return klass
194
195 smart_text = smart_unicode
196 force_text = force_unicode
197 smart_bytes = smart_str
198
199 # Added by Haibo Hao
# Forwords compatibillity with Django 1.5
# Added by Haibo Hao
def python_2_unicode_compatible(klass):
# Always use the Python 2 branch of the decorator here in Django 1.4
klass.__unicode__ = klass.__str__
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
return klass
smart_text = smart_unicode
force_text = force_unicode
smart_bytes = smart_str
# Added by Haibo Hao
添加上面代码的参考来源
https://stackoverflow.com/questions/20463771/importerror-cannot-import-name-force-text
https://github.com/django/django/blob/stable/1.4.x/django/utils/encoding.py
这个地方有问题!!! 暂时不能按下面这样改
如果还有下面这个错误
AttributeError: ‘Nonetype’ object has no attribute ‘_info’
解决办法参考:
https://stackoverflow.com/questions/31816158/attributeerror-nonetype-object-has-no-attribute-info/32358780#32358780
修改后,再次执行
./manage.py runserver
出现 no name six的错误
在
/home/hhb/work/catmaid_5d_visualization_annotation/django/env/lib/python2.7/site-packages/django/utils
路径下添加文件
six.py
six.py文件来源
Django github 1.4.x稳定版中的six.py文件
https://github.com/django/django/tree/stable/1.4.x
接下来执行数据库迁移
./manage.py migrate
再执行
./manage.py runserver
出现访问的url没有匹配的错误
发现我们实际访问的url是http://127.0.0.1:8000//
这个时候
修改settings.py文件
路径为
/home/hhb/work/catmaid_5d_visualization_annotation/django/projects/mysite/settings.py
找到
FORCE_SCRIPT_NAME = '/'
这一行
对,就是这行搞的鬼
强行加了’/’
然后要做的是把它注释掉
#FORCE_SCRIPT_NAME = '/'
这个时候就可以访问
http://127.0.0.1:8000