Make組ブログ

Python、Webアプリや製品・サービス開発についてhirokikyが書きます。

django-blog-zinnia導入時のハマりどころ2点

Django製サイトにブログを導入するdjango-blog-zinniaについて、ハマりどころ書く。

以下2点でハマった。

  1. Error: One or more models did not validate
  2. TemplateSyntaxError at /weblog/

環境

Error: One or more models did not validate

ドキュメントの
GettingStarted > Installation
が終わり、データベースと同期を取ろうとした際に

Error: One or more models did not validate:
zinnia.entry: "image": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .

とのこと。
みるとPILが無いと言われたので

% sudo pip install PIL

で解決。

エラーによるとImageFields使うのにPILが要るとのこと。
ドキュメントにはPILが必要とは書いてなかった気がするけど。

TemplateSyntaxError at /weblog/

syncdb、runserver後、

にアクセスすると

TemplateSyntaxError at /weblog/
'comments' is not a valid tag library: Template library comments not found, tried django.templatetags.comments,django.contrib.staticfiles.templatetags.comments,django.contrib.admin.templatetags.comments,tagging.templatetags.comments,mptt.templatetags.comments,zinnia.templatetags.comments

と出る。

これは INSTALLED_APPS に 'django.contrib.commets' を追加していないのが原因と思われる。

#Requirements for django-blog-zinnia
INSTALLED_APPS += (
    'django.contrib.comments',
    'tagging',
    'mptt',
    'zinnia',
)

※実際はこんな書き方してない

これで問題なく走ると思う。

おわりに

『インストール方法』みたいな記事は気が向いたら書くつもり。

昨日の記事

とあわせればユーザグループのサイトはある程度作れるようになったと思う。
/docs/ 以下でドキュメント、 /weblog/ 以下で新着情報配信できれば最低限ではあるだろうから。