NoReverseMatch implementing django-likes -
getting next error when trying install django-likes
noreversematch @ /post/25/
reverse '' arguments '('posts-post', 25, 1)' , keyword arguments '{}' not found. 0 pattern(s) tried: []
exception location: /users/pete/.virtualenvs/innerlocal-mvp/lib/python2.7/site-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 463
i'm not sure start on error, i've done lot of searching, nil comes up.
my view referring to:
def single_post(request, id): post = get_object_or_404(post, id=id) ... homecoming render(request, 'posts/single_post.html', locals())
with {% likes post %} in html.
and line highlighted resulting html:
<a class="liker" href="{% url content_type content_obj.id 1 %}" rel="nofollow">{% trans "i like" %}</a>
i'm using django 1.7 wouldn't surprised if problem.
any help appreciated!!
extra settings requested:
the urls.py lines (first, app, second, django-likes url:
url(r'^', include('posts.urls')), (r'^likes/', include('likes.urls')),
and urls.py posts app:
from django.conf import settings django.conf.urls import patterns, include, url django.views.generic import templateview views import postdelete urlpatterns = patterns('posts.views', # (r'^', 'home'), url(r'^$', 'all_posts', name='home'), url(r'^post/(?p<id>\w+)/$', 'single_post', name='single_post'), url(r'^new-post/$', 'new_post', name='new_post'), url(r'^search/$', 'search', name='search'), url(r'^delete/(?p<pk>\d+)/$', postdelete.as_view(), name='entry_delete'), )
installed apps:
installed_apps = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', 'django.contrib.sites', .... 'secretballot', 'likes', )
middleware classes:
middleware_classes = ( 'django.middleware.gzip.gzipmiddleware', 'pipeline.middleware.minifyhtmlmiddleware', '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.contrib.redirects.middleware.redirectfallbackmiddleware', 'secretballot.middleware.secretballotipmiddleware', 'secretballot.middleware.secretballotipuseragentmiddleware', 'likes.middleware.secretballotuseripuseragentmiddleware', )
template context processors:
template_context_processors = ( "django.core.context_processors.request", "allauth.account.context_processors.account", "allauth.socialaccount.context_processors.socialaccount", "django.contrib.auth.context_processors.auth", "django.core.context_processors.static", "django.core.context_processors.media", "django.contrib.messages.context_processors.messages", )
turns out app code needed change:
in likes.html
from
<a class="liker" href="{% url content_type content_obj.id 1 %}" rel="nofollow">{% trans "i like" %}</a>
to
<a class="liker" href="{% url 'like' content_type content_obj.id 1 %}" rel="nofollow">{% trans "i like" %}</a>
ie - quotation marks around 'like'
django
No comments:
Post a Comment