2012-03-30 9 views
0

Djangoの組み込みコメントフレームワークを他のページに使用できるかどうかは疑問ですが、これは「ブログエントリ」には関係ありません。たとえば、映画に関する各ページにコメントフィールドを追加したいとします。他のページでDjangoのコメントを使うことはできますか?

私はここの指示に従おうとしましたが、https://docs.djangoproject.com/en/dev/ref/contrib/comments/が次のエラーを受けました。私はすでに必要なAPPを追加し、syncdbを実行しました。

Environment: 


Request Method: GET 
Request URL: http://localhost:8000/movie/603/ 

Django Version: 1.4 
Python Version: 2.7.2 
Installed Applications: 
('django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.admin', 
'forms', 
'social_auth') 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware') 


Template error: 
In template C:\xampp\htdocs\tddd27_project\templates\movie_info.html, error at line 3 
    '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,forms.templatetags.comments 
    1 : {% extends "base.html" %} 


    2 : {% load string_extras %} 


    3 : {% load comments %} 


    4 : {% block title %}{{ content.original_title }}{% endblock title %} 


    5 : {% block content %} 


    6 : 


    7 : <h2>{{ content.original_title }} - ({{ content.release_date|year}})</h2> 


    8 : <table> 


    9 :  <tr> 


    10 :    <td><img src="http://cf2.imgobject.com/t/p/w185/{{ content.poster_path}}"></td> 


    11 :    <td>{{ content.overview }}</td> 


    12 :   </tr> 


    13 : 


Traceback: 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\core\handlers\base.py" in get_response 
    111.       response = callback(request, *callback_args, **callback_kwargs) 
File "C:\xampp\htdocs\tddd27_project\views.py" in movie_view 
    65. return render_to_response('movie_info.html',{'content':content}, RequestContext(request)) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\shortcuts\__init__.py" in render_to_response 
    20.  return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader.py" in render_to_string 
    169.   t = get_template(template_name) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader.py" in get_template 
    145.  template, origin = find_template(template_name) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader.py" in find_template 
    134.    source, display_name = loader(name, dirs) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader.py" in __call__ 
    42.   return self.load_template(template_name, template_dirs) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader.py" in load_template 
    48.    template = get_template_from_string(source, origin, template_name) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader.py" in get_template_from_string 
    156.  return Template(source, origin, name) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\base.py" in __init__ 
    125.   self.nodelist = compile_string(template_string, origin) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\base.py" in compile_string 
    153.  return parser.parse() 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\base.py" in parse 
    267.      compiled_result = compile_func(self, token) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\loader_tags.py" in do_extends 
    214.  nodelist = parser.parse() 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\base.py" in parse 
    267.      compiled_result = compile_func(self, token) 
File "c:\tools\python27\lib\site-packages\django-1.4-py2.7.egg\django\template\defaulttags.py" in load 
    1043.           (taglib, e)) 

Exception Type: TemplateSyntaxError at /movie/603/ 
Exception Value: '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,forms.templatetags.comments 
+1

...そのリストにあるように表示されません構文エラーがある場合は、私たちが見ることができるので、あなたのモデルとテンプレートコードを投稿できますか? –

答えて

5

ここで何か不足して見えることがありますか?

Installed Applications: 
('django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.admin', 
'forms', 
'social_auth') 

django.contrib.commentsが、これはただのモデルについて取り組む必要があります

+0

ああ、私はずっとずっと見つめていて、 'django.contrib.messages'がその一人だと思っていました.... -_- ;;;;; – starcorn

+1

Djangoのメッセージは、基本的にはINFO、SUCCESS、ERROR、WARNINGのように即座に表示されるメッセージを作成します。例えば、新しい写真をアップロードした場合に、成功したことをユーザーに表示したい場合は、 – ApPeL

関連する問題