WSGIRequest error using django_model_comments - django

Sorry to post yet another question related to the error:
'WSGIRequest' object has no attribute 'find'
But I really can't find the answer anywhere.
I'm trying to use the django_model_comments app, which extends django's included comment app.
Did everything the page tells, however when running the server, I get the following:
Environment:
Request Method: GET
Request URL: http://localhost:8000/feed/1
Django Version: 1.4.3
Python Version: 2.7.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'model_comments',
'django.contrib.comments',
'pinax_theme_bootstrap_account',
'pinax_theme_bootstrap',
'django_forms_bootstrap',
'account',
'metron',
'user_app',
'feed_app']
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 D:\Docs\Work\repo\project\feed_app\templates\feed.html, error at line 10
'WSGIRequest' object has no attribute 'find'
1 : {% load model_comment_tags %}
2 : {% get_comment_form for feed as post_form %}
3 : {% render_comment_form post_form %}
Traceback:
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "D:\Docs\Work\repo\project\feed_app\views.py" in get_user_feed
37. 'feed': private_feed})
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\base.py" in render
140. return self._render(context)
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\base.py" in _render
134. return self.nodelist.render(context)
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\base.py" in render
823. bit = self.render_node(node, context)
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\debug.py" in render_node
74. return node.render(context)
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\defaulttags.py" in render
281. return nodelist.render(context)
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\base.py" in render
823. bit = self.render_node(node, context)
File "D:\Docs\Work\repo\so_virtual_env\lib\site-packages\django\template\debug.py" in render_node
74. return node.render(context)
File "D:\Docs\Work\repo\project\model_comments\templatetags\model_comment_tags.py" in render
26. return self.func(context)
File "D:\Docs\Work\repo\project\model_comments\templatetags\model_comment_tags.py" in wrap
75. form.set_request(request)
File "D:\Docs\Work\repo\project\model_comments\forms.py" in set_request
106. self.fields['from_url'].initial = unicode(Url(request))
File "D:\Docs\Work\repo\project\model_comments\url_util.py" in __init__
11. self.scheme, self.netloc, self.path, self.params, self.query_string, self.fragment = urlparse.urlparse(url)
File "C:\Python27\Lib\urlparse.py" in urlparse
134. tuple = urlsplit(url, scheme, allow_fragments)
File "C:\Python27\Lib\urlparse.py" in urlsplit
173. i = url.find(':')
Exception Type: AttributeError at /feed/1
Exception Value: 'WSGIRequest' object has no attribute 'find'
And the error happens when a templatetag is used:
html = "{% load model_comment_tags %} \
{% get_comment_form for feed as post_form %}\
{% render_comment_form post_form %}"
t = template.Template(html)
html = t.render(RequestContext(request, {'feed': private_feed}))
I've checked all my middleware, the order of apps, deleted .pyc files, and made all sorts of experiments in the template.

There's a bug in the django_model_comments library, because here they pass the HttpRequest object, not a string which is what the Url class here is expecting, so instead it should call the build_absolute_uri() method on the request object and then pass the string to the Url class.
So basically replace
unicode(Url(request))
with
unicode(Url(request.build_absolute_uri()))

Related

calling a django view recursively

I am trying to call a view recursively. Below is my code.
views.py
def survey_start(request):
post = models.Post.objects.all().order_by('id')
return HttpResponseRedirect(reverse('post_form_upload',args=(post[0].id,)))
def post_form_upload(request, id):
post = get_object_or_404(models.Post, id=id)
if request.method == 'GET':
content = post.content
form = CommentModelForm(content = content)
else:
form = CommentModelForm(request.POST)
if form.is_valid():
message = form.cleaned_data['message']
created_at = form.cleaned_data['created_at']
post1 = models.Comment.objects.create(post = id,
message = message,
created_at = created_at)
return HttpResponseRedirect(reverse('post_form_upload',
args= (post.next_id,)))
return render(request, 'survey_forms/post_form_upload.html',{
'form':form,
})
urls.py
urlpatterns = [
url(r'^post/form_upload.html$',views.survey_start, name='survey_start'),
url(r'^post/(?P<id>\d+)/post_form_upload.html$',views.post_form_upload, name='post_form_upload'),
]
I have two questions.
1. I keep on getting this error. It does enter the view. I printed a counter to check.
Reverse for 'post_form_upload' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['survey_forms/post/(?P<id>\\d+)/post_form_upload.html$']
Here is the traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/survey_forms/post/1/post_form_upload.html
Django Version: 1.8.3
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'survey',
'dynamic_forms',
'crispy_forms',
'formtools',
'survey_forms')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'dynamic_forms.middlewares.FormModelMiddleware')
Template error:
In template /Users/Desktop/VtStudy/python/django/2dj_proto/mysurvey/survey_forms/templates/survey_forms/post_form_upload.html, error at line 1
Reverse for 'post_form_upload' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['survey_forms/post/(?P<id>\\d+)/post_form_upload.html$']
1 : <form action=" {% url 'post_form_upload' %} " method='post'>
2 : {% csrf_token %}
3 :
4 : {{form.as_p}}
5 : <input type='submit' value='Submit'/>
6 : </form>
Traceback:
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/Desktop/VtStudy/python/django/2dj_proto/mysurvey/survey_forms/views.py" in post_form_upload
132. 'form':form,
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/shortcuts.py" in render
67. template_name, context, request=request, using=using)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/template/loader.py" in render_to_string
99. return template.render(context, request)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site-packages/django/template/backends/django.py" in render
74. return self.template.render(context)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/template/base.py" in render
209. return self._render(context)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/template/base.py" in _render
201. return self.nodelist.render(context)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site-packages/django/template/base.py" in render
903. bit = self.render_node(node, context)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/template/debug.py" in render_node
79. return node.render(context)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/template/defaulttags.py" in render
507. six.reraise(*exc_info)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site-packages/django/template/defaulttags.py" in render
493. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site- packages/django/core/urlresolvers.py" in reverse
579. return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
File "/Users/.virtualenvs/2dj_proto/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
496. (lookup_view_s, args, kwargs, len(patterns), patterns))
Exception Type: NoReverseMatch at /survey_forms/post/1/post_form_upload.html
Exception Value: Reverse for 'post_form_upload' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['survey_forms/post/(? P<id>\\d+)/post_form_upload.html$']
Each post is displayed in one single page. The user must navigate from one page to other on clicking "next". So I am calling this view post_upload_form recursively. Is this the right approach?
Thanks.
For first point: problem is in the template:
<form action=" {% url 'post_form_upload' %} " method='post'>
post_form_upload in your urls.py takes one non-empty argument, but you're not providing that in above line.
For second point: this is not an recursion, technically speaking. You are just redirecting user to next url, which is handled by same view function. And it is right approach, there is nothing wrong with that.

django-debug-toolbar: 'list' does not support the buffer interface

I made a few modifications to my model, adding some image fields and installing Pillow, deleteing some models or model fields.
As Site is not yet in production, I simply dropped the database and re-created it, and synced it. Then I got this error.
I can't figure out what could be the source of this sudden error. In the settings.py I added a media_root but nothing else.
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.6.2
Python Version: 3.4.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'backoffice',
'public',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
'widget_tweaks',
'rosetta',
'debug_toolbar',
'template_debug')
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Template error:
In template C:\Python34\lib\site-packages\debug_toolbar\templates\debug_toolbar\base.html, error at line 5
'list' does not support the buffer interface
1 : {% load i18n %}{% load static from staticfiles %}{% load url from future %}
2 : <style type="text/css">
3 : #media print { #djDebug {display:none;}}
4 : </style>
5 : <link rel="stylesheet" href=" {% static 'debug_toolbar/css/toolbar.css' %} " type="text/css" />
6 : {% if toolbar.config.JQUERY_URL %}
7 : <script src="{{ toolbar.config.JQUERY_URL }}"></script>
8 : <script>var djdt = {jQuery: jQuery.noConflict(true)};</script>
9 : {% else %}
10 : <script>var djdt = {jQuery: jQuery};</script>
11 : {% endif %}
12 : <script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
13 : <div id="djDebug" style="display:none;" dir="ltr"
14 : data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"
15 : {{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>
Traceback:
File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
201. response = middleware_method(request, response)
File "C:\Python34\lib\site-packages\debug_toolbar\middleware.py" in process_response
121. bits[-2] += toolbar.render_toolbar()
File "C:\Python34\lib\site-packages\debug_toolbar\toolbar.py" in render_toolbar
68. return render_to_string('debug_toolbar/base.html', context)
File "C:\Python34\lib\site-packages\django\template\loader.py" in render_to_string
164. return t.render(Context(dictionary))
File "C:\Python34\lib\site-packages\django\template\base.py" in render
140. return self._render(context)
File "C:\Python34\lib\site-packages\django\test\utils.py" in instrumented_test_render
85. return self.nodelist.render(context)
File "C:\Python34\lib\site-packages\django\template\base.py" in render
840. bit = self.render_node(node, context)
File "C:\Python34\lib\site-packages\django\template\debug.py" in render_node
78. return node.render(context)
File "C:\Python34\lib\site-packages\django\templatetags\static.py" in render
106. url = self.url(context)
File "C:\Python34\lib\site-packages\django\contrib\staticfiles\templatetags\staticfiles.py" in url
12. return staticfiles_storage.url(path)
File "C:\Python34\lib\site-packages\django\utils\functional.py" in inner
213. self._setup()
File "C:\Python34\lib\site-packages\django\contrib\staticfiles\storage.py" in _setup
311. self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
File "C:\Python34\lib\site-packages\django\contrib\staticfiles\storage.py" in __init__
37. *args, **kwargs)
File "C:\Python34\lib\site-packages\django\core\files\storage.py" in __init__
154. self.location = abspathu(self.base_location)
File "C:\Python34\lib\ntpath.py" in abspath
545. path = _getfullpathname(path)
Exception Type: TypeError at /
Exception Value: 'list' does not support the buffer interface
All right, my fault. Error was in fact pretty explicit.
Unlike the TEMPLATE_DIRS, MEDIA_ROOT is not supposed to be a list.
Django Debug toolbar will return an error every time you mess up with variables types in
the "settings.py" file.
In case anyone does similar mistakes, I'll leave Q&A here.

django-openid-auth: TemplateSyntaxError

I'm trying to set up django-openid-auth on my django project. I've followed steps 1-8 of the provided guide and have tried going to /openid/login/ on my server. However, when I go to that page I see
TemplateSyntaxError at /openid/login/
Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.
I'm a bit confused since this is in a template included in the app - I didn't write the template myself. If anybody knows what I'm doing wrong, I'd really appreciate some help.
Here's my stacktrace:
Environment:
Request Method: GET
Request URL: http://localhost:8000/openid/login/
Django Version: 1.5.2
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'wseeruploader.apps.fileupload',
'django_openid_auth',
'crispy_forms')
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 /usr/lib/python2.7/site-packages/django_openid_auth/templates/openid/login.html, error at line 8
Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.
1 : {% load i18n %}
2 : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3 : <html>
4 : <head>
5 : <title>Sign in with your OpenID</title>
6 : <style type="text/css">
7 : input.openid {
8 : background: url( {% url openid-logo %} ) no-repeat;
9 : background-position: 0 50%;
10 : padding-left: 16px;
11 : }
12 : </style>
13 : </head>
14 : <body>
15 : <h1>Sign in with your OpenID</h1>
16 : {% if form.errors %}
17 : <p class="errors">{% trans "Please correct errors below:" %}<br />
18 : {% if form.openid_identifier.errors %}
Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django_openid_auth/views.py" in login_begin
171. }, context_instance=RequestContext(request))
File "/usr/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
29. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
170. t = get_template(template_name)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in get_template
146. template, origin = find_template(template_name)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in find_template
135. source, display_name = loader(name, dirs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in __call__
43. return self.load_template(template_name, template_dirs)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in load_template
49. template = get_template_from_string(source, origin, template_name)
File "/usr/lib/python2.7/site-packages/django/template/loader.py" in get_template_from_string
157. return Template(source, origin, name)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in __init__
125. self.nodelist = compile_string(template_string, origin)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in compile_string
153. return parser.parse()
File "/usr/lib/python2.7/site-packages/django/template/base.py" in parse
274. compiled_result = compile_func(self, token)
File "/usr/lib/python2.7/site-packages/django/template/defaulttags.py" in url
1266. viewname = parser.compile_filter(bits[1])
File "/usr/lib/python2.7/site-packages/django/template/base.py" in compile_filter
353. return FilterExpression(token, self)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in __init__
570. "from '%s'" % (token[upto:], token))
Exception Type: TemplateSyntaxError at /openid/login/
Exception Value: Could not parse the remainder: '-logo' from 'openid-logo'. The syntax of 'url' changed in Django 1.5, see the docs.
Since you are using django-1.5
You should change:
{% url openid-logo %}
to
{% url 'openid-logo' %}
Relevant documentation can be found in the release notes
The upshot of this is that if you are not using {% load url from future %} in your templates, you’ll need to change tags like {% url myview %} to {% url "myview" %}. If you were using {% load url from future %} you can simply remove that line under Django 1.5

CSRF fails when trying to upload ImageField

I have a django template with an ImageField form to allow users to upload pictures on the site.
1) The form contains {% csfr_token %}
2) I render a template with render variables.
Also, I have set enctype="multipart/form-data" in the form in the template?
Still I get a CSFR verif. fail. Can anyone help?
Code from the template.html
<form enctype="multipart/form-data" action='{% url photo username %}' method="post">
{% csrf_token %}
<p>{{ form.non_field_errors }}</p>
<p>{{ form.profile_picture.label_tag }} {{ form.profile_picture.help_text }}</p>
<p>
{{ form.profile_picture.errors }}
{{ form.profile_picture }}
</p>
<p><input type="submit" value="Upload" /></p>
</form>
The view:
def upload_photo(request, nick):
#c = {}
#c.update(csrf(request))
if request.method == 'POST':
form = PictureForm(request.POST, request.FILES)
if form.is_valid():
newpic = Picture(profile_picture = request.FILES['profile_picture'])
newpic.save()
# Redirect to the document list after POST
return HttpResponseRedirect(reverse('profiles.views.upload_photo', args=[nick]))
else:
form = PictureForm() # A empty, unbound form
# Load documents for the list page
pictures = Picture.objects.all()
# Render list page with the documents and the form
return render_to_response(
'profile.html',
#various render variables here
})
UPDATE:traceback
Environment:
Request Method: POST
Request URL: localhost/hello/john/
Django Version: 1.4.2
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',
'django.contrib.admindocs',
'friendship',
'search',
'tour',
'profiles')
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')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/mike/Documents/ics/django/ics/profiles/views.py" in upload_photo
18. newpic.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
463. self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save_base
551. result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in _insert
203. return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in insert_query
1593. return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
909. for sql, params in self.as_sql():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in as_sql
872. for obj in self.query.objs
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in pre_save
249. file.save(file.name, file, save=False)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in save
85. name = self.field.generate_filename(self.instance, name)
File "/home/mike/Documents/ics/django/ics/profiles/models.py" in get_image_name
8. name = str(instance.user_id) + ".jpg"
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py" in __get__
343. raise self.field.rel.to.DoesNotExist
I found that the error is here (models.py):
def get_image_name(instance, filename):
return str(instance.user_id) + ".jpg"
#str(____) + ".jpg" causes the exception
class Picture(models.Model):
user_id = models.ForeignKey(User)
profile_picture = models.ImageField(storage=OverwriteStorage(), upload_to=get_image_name)
Any thoughts why this happens?
What I'm trying to do is save the image the user uploads with their username. But how can I get the user's username within the models.py?
Since you are not manually updating your context with the csrf token you must use a RequestContext in your render to response method
return render_to_response('profile.html', {
..your data dict.. }, context_instance=RequestContext(request))
Please see https://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext as well (I link to an old version of django since you still use function-style views)
EDIT:
Now that the csrf problem is fixed, you're dealing with a separate, new error. Try changing 'user_id' to 'user' (for consistency) in your Picture model and use str(instance.user.username) in your get_image_name. Even if this does not work (which it normally should), please post a new question as the original request has been answered. People could search for csrf and end up here, reading for an unrelated problem.

can I use Django comment on other pages?

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...