0

I am using this plugin

There was an error with the url so I changed it from

<a class="liker" href="{% url like content_type content_obj.id 1 %}" rel="nofollow">I Like</a>`

to

<a class="liker" href="{% url 'like' content_type content_obj.id 1 %}" rel="nofollow">I Like</a>

as recommended in this fix but I am still getting this error

Reverse for 'like' with arguments '(u'snippets-snippets', None, 1)' and keyword arguments '{}' not found.

EDIT: This is the urls.py from the app

urlpatterns = patterns(
    'likes.views',
    url(r'^like/(?P<content_type>[\w-]+)/(?P<id>\d+)/(?P<vote>-?\d+)$', 'like',
        name='like'),
)

My urls.py simply includes it

urlpatterns = patterns('snippets.views',
    (r'^likes/', include('likes.urls')),
)
4

1 回答 1

1

Looking at your error, it seems like your content_obj.id is evaluating to None. You might want to see if that object indeed exists. If not, you might have to do a sanity check. Something like

{% if content_obj.id %}
    <a class="liker" href="{% url 'like' content_type content_obj.id 1 %}" rel="nofollow">I Like</a>
{% endif %}

Or pass the content_obj in the context appropriately.

于 2013-07-29T03:01:36.303 回答