locale信息
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
getfilesystemencoding
In [2]: sys.getfilesystemencoding()
Out[2]: 'UTF-8'
apache
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jan 14 2016 17:45:23
models
'''
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
Create your models here.
class Post(models.Model):
author = models.ForeignKey(User)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True,null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
'''
错误提示
'''
UnicodeEncodeError at /admin/blog/post/2/change/
'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Request Method: POST
Request URL: http://www.liaoixue.com/admin/blog/post/2/change/
Django Version: 1.9.7
Exception Type: UnicodeEncodeError
Exception Value:
'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Exception Location: /home/ubuntu/simpleblog/env3.4/lib/python3.4/site-packages/django/utils/encoding.py in force_text, line 80
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/home/ubuntu/simpleblog/mysite',
'/home/ubuntu/simpleblog/env3.4/lib/python3.4/site-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/gtk-2.0']
Server time: 星期四, 23 六月 2016 09:24:42 +0800
Unicode error hint
The string that could not be encoded/decoded was: 中文标题
'''
日志
Traceback: http://dpaste.com/0TER50K.txt
日志中显示: Python Version: 2.7.6
换成 python 3来启动