My Own Like Button: Django + Ajax — How?

前端 未结 2 577
予麋鹿
予麋鹿 2020-11-30 23:08

So I\'ve been having trouble turning this view into an Ajax call:

def company_single(request, slug):
    company = get_object_or_404(CompanyProfile, slug=slu         


        
2条回答
  •  再見小時候
    2020-11-30 23:51

    Writing this here since I don't have enough reputation to comment and edits have to be at least 6 characters. In new versions of Django, you need to pass the path to the view function or the name of the url to the url template tag as a string. Therefore line 7 of above template would be:

    url: "{% url 'like' %}",
    

    Here is the part of the documentation that backs this up.

提交回复
热议问题