チュートリアル その4

  1. 遂行中。相変わらず typo によるエラーが多く、発見・修正に手間取る(自業自得)
  2. 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)
  3. template(detail.hml)10行目
    <input type="submit" value="投票する" />
    は問題無い
  4. エラーメッセージ中の URIPEP 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 (略)
  5. /polls/views.py 1行目に # coding= を追加する
  6. リロード → エラー
  7. 同文書の続きを読む → … !
  8. /polls/views.py 1行目を # coding=utf-8 に変更する
  9. リロード → 日本語表示サレタヨ
  10. 続く