title: Pass date year month slug in html template ajax post request
body: <p>I have a blogost, comment and like model. The like model has a genericforeignkey field so I can link likes to blogposts and comments.    </p>
  
  <p>The view is working correctly however I am having trouble passing the parameters in the ajax request</p>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>urlpatterns =[
  url(r'^$',views.home, name = 'home'),
  
  url(r'^blog/(?P&lt;year&gt;[0-9]{4})/(?P&lt;month&gt;[0-9]{1,2})/(?P&lt;day&gt;[0-9]{1,2})/(?P&lt;slug&gt;[-\w]+)/$', 
  views.blog,
  name = 'view_blogpost_with_pk'),
  
  url(r'^blog/(?P&lt;year&gt;[0-9]{4})/(?P&lt;month&gt;[0-9]{1,2})/(?P&lt;day&gt;[0-9]{1,2})/(?P&lt;slug&gt;[-\w]+)/ajax/like/$',VotesView.as_view(model=BlogPost, vote_type=Like.LIKE),
         name='blog_like'),
  
  url(r'^blog/(?P&lt;year&gt;[0-9]{4})/(?P&lt;month&gt;[0-9]{1,2})/(?P&lt;day&gt;[0-9]{1,2})/(?P&lt;slug&gt;[-\w]+)/ajax/dislike/$', VotesView.as_view(model=BlogPost, vote_type=Like.DISLIKE),
         name='blog_dislike'),  
  </code></pre>
  
  <p>]</p>
  
  <p><strong>blog.html</strong></p>
  
  <pre><code>    &lt;ul&gt;
        &lt;li data-id="{{ like_obj.id }}" data-type="blog" data-action="like" title="Like"&gt;
            &lt;span class="glyphicon glyphicon-thumbs-up"&gt;&lt;/span&gt;
            &lt;span data-count="like"&gt;{{ like_obj.votes.likes.count }}&lt;/span&gt;
        &lt;/li&gt;
        &lt;li data-id="{{ like_obj.id }}" data-type="blog" data-action="dislike" title="Dislike"&gt;
            &lt;span class="glyphicon glyphicon-thumbs-down"&gt;&lt;/span&gt;
            &lt;span data-count="dislike"&gt;{{ like_obj.votes.dislikes.count }}&lt;/span&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
  </code></pre>
  
  <p>And the javascript. Just including dislike, like is very similar</p>
  
  <pre><code> &lt;script&gt;
   function dislike()
  {
      var dislike = $(this);
      var type = dislike.data('type');
      var pk = dislike.data('id');
      var action = dislike.data('action');
      var like = dislike.prev();
  
  $.ajax({
      url : '/home/blog/2017/10/1/git/ajax/dislike/',
      method : 'POST',
      data : { 'obj' : pk },
  
      success : function (json) {
          dislike.find("[data-count='dislike']").text(json.dislike_count);
          like.find("[data-count='like']").text(json.like_count);
      }
  });
  
  return false;
  }
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;script&gt;
  $(function() {
      $('[data-action="like"]').click(like);
      $('[data-action="dislike"]').click(dislike);
  });
   &lt;/script&gt;
  </code></pre>
  
  <p>So at the moment this working great except when i replace url with </p>
  
  <pre><code>url: '{% url "home:blog_dislike" year=obj.year month=obj.month day=obj.date 
  slug=obj.slug %}'
  </code></pre>
  
  <p>I get  </p>
  
  <pre><code>django.urls.exceptions.NoReverseMatch: Reverse for 'blog_like' with keyword 
  arguments '{'year': '', 'month': '', 'day': '', 'slug': ''}' not found. 1 
  pattern(s) tried: ['home/blog/(?P&lt;year&gt;[0-9]{4})/(?P&lt;month&gt;[0-9]{1,2})/(? 
  P&lt;day&gt;[0-9]{1,2})/(?P&lt;slug&gt;[-\\w]+)/ajax/like/$']
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def blog(request,year,month,day,slug):
  
  if request.method == 'GET':
  
      blogpost = BlogPost.objects.get(date__year=year, date__month=month, date__day=day,slug=slug)
  
      form = BlogPostForm()
      comments = Comment.objects.filter(comment_body_id=blogpost).order_by('-date') #Link comments to blogpost // comment_body is foreignkey to blogpost model
      c = comments.count()
  
  
      args = {'bpost': blogpost,'form':form,'comments':comments,'c':c}
      return render(request,'home/blog.html',args)    
  
  if request.method == 'POST':
  
      blogpost = BlogPost.objects.get(date__year=year, date__month=month, date__day=day,slug=slug)
  
      form = BlogPostForm(request.POST)
      if form.is_valid():
          comment = form.save(commit = False)
          comment.comment_body = blogpost
          comment.save()
          text = form.cleaned_data['comment']
          form = BlogPostForm()
          return redirect(request.build_absolute_uri())
  
  else:
      form = BlogPostForm()
  
      args = {'form':form,'text':text}
      return render(request, 'home/blog.html', args)   
  
  
  
  class VotesView(View):
      model = None  
      vote_type = None 
  
  
  
  def post(self,request, year, month, day, slug):
  
      obj = self.model.objects.get(date__year=year, date__month=month, date__day=day,slug=slug)
  
      try:
          x = Like.objects.get(content_type=ContentType.objects.get_for_model(obj), object_id=obj.id, user=request.user)
          if x.vote is not self.vote_type:
              x.vote = self.vote_type
              x.save(update_fields = ['vote'])
              result = True
          else:
              x.delete()
              result = False
      except Like.DoesNotExist:   
          obj.votes.create(user=request.user, vote=self.vote_type) 
          result = True
  
      return HttpResponse(
          json.dumps({
              "result": result,
              "like_count": obj.votes.likes().count(),
              "dislike_count": obj.votes.dislikes().count(),
              "sum_rating": obj.votes.sum_rating()
          }),
          content_type="application/json"
      )
  </code></pre>
  
  <p>Thank you for any help</p>