I am currently porting over some django 0.97 code to django 1.3.1 code.

I keep getting the following django error:

TemplateSyntaxError at /dir1/dir2/
Caught ImportError while rendering: No module named comments

The error keeps pointing to the following line <a href = "{% url testpage %}">testpage</a>

I do have 'django.contrib.comments' in my settings.py file. I am running django 1.3.1 and python 2.7.

The trace shows the following error

/usr/lib/python2.7/dist-packages/django/utils/importlib.py in import_module
__import__(name)
▼ Local vars
Variable    Value
name    'django.contrib.comments.urls.comments'
package None

Any ideas on how to solve this?

Update 1: I am Looking into this https://docs.djangoproject.com/en/1.1/ref/contrib/comments/upgrade/

Update 2: To solve my problem I did the following.

Changed

(r'^admin/', include('django.contrib.admin.urls')),

to

(r'^admin/', include(admin.site.urls)),

changed

(r'^comments/', include('django.contrib.comments.urls.comments')),

to

(r'^comments/', include('django.contrib.comments.urls')),
有帮助吗?

解决方案

Check your url patterns where you include the comments urls. The comments quick start guide says you should have something like:

urlpatterns = patterns('',
    ...
    (r'^comments/', include('django.contrib.comments.urls')),
    ...
)

Whereas you error message in the traceback suggests you may have django.contrib.comments.urls.comments hardcoded somewhere.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top