0

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)
2

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

I did but it didn't help
I am sorry. I think it was my spelling miss or something. I also did wrote coding: utf-8 but after copying your one, it does work.
the cause was not about coding type. it was that I added field display name even to foreign key's column.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.