문제

I wonder whether it is possible to use Django in-built comments framework for other pages, that is not related to "blog entries". For example I want to add comments field on each every page about a movie.

I tried to follow the instructions here https://docs.djangoproject.com/en/dev/ref/contrib/comments/ but got the following error. I already added the necessary APP, and did 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
도움이 되었습니까?

해결책

Can you see something missing here?

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 does not appear to be in that list...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top