Well, maybe this answer can help you.
Put # -*- coding: utf-8 -*-
at top of file, it define de encoding to utf-8 which is what you need
Вопрос
I'd like to assign a human-readble name in Japanese that appears in Admin site.
so, simply I'd like to write like this way:
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField(u'投稿日時')
But then it says:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 57:
ordinal not in range(128)
How can I use unicode like Japanese in this case ?
full traceback:
python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/me/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/me/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/me/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/me/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/base.py", line 284, in execute
self.validate()
File "/Users/me/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/base.py", line 314, in validate
raise CommandError("One or more models did not validate:\n%s" % error_text)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 57: ordinal not in range(128)
Решение
Well, maybe this answer can help you.
Put # -*- coding: utf-8 -*-
at top of file, it define de encoding to utf-8 which is what you need