チュートリアル その4
- 遂行中。相変わらず typo によるエラーが多く、発見・修正に手間取る(自業自得)
- views.py の日本語が SyntaxError になる
SyntaxError at /polls/
Non-ASCII character '\xe6' in file /PATH/TO/mysite/polls/views.py on line 19, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details (views.py, line 19) - template(detail.hml)10行目
は問題無い<input type="submit" value="投票する" />
- エラーメッセージ中の URI(PEP 263 -- Defining Python Source Code Encodings | Python.org) にアクセスする
Defining the Encoding
Python will default to ASCII as standard encoding if no other
encoding hints are given.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, such as:
# coding=
or (略)
- /polls/views.py 1行目に
# coding=
を追加する - リロード → エラー
- 同文書の続きを読む → … !
- /polls/views.py 1行目を
# coding=utf-8
に変更する - リロード → 日本語表示サレタヨ
- 続く