I'm making a blog using Django 1.9 and I've run into problem while implememting a upvote system in the website.
<form action="{% url 'blogapp:vote_handler' id=instance.get_id %}" method="POST" id="upvote_form_post">
{% csrf_token %}
<input type="hidden" name="user" value="{{request.user}}">
<input type="hidden" name="content_type_upvote" value="{{ instance.get_content_type }}">
<input type="hidden" name="object_id_upvote" value="{{ instance.get_id }}">
<button type="submit" class="icon fa-heart button-link" name="upvote_form_post" value="Submit">  {{ instance.vote_count }}</button>
</form>
This form has been giving me problems, particularly the action attribute with the url.
my url file :
urlpatterns = [
# url(r'^$', views.IndexView.as_view(), name='list'),
url(r'^$', post_list, name='list'),
url(r'^create/$', post_create),
url(r'^(?P<slug>[\w-]+)/$', views.post_detail, name='detail'),
url(r'^(?P<slug>[\w-]+)/delete/$', views.DeleteView.as_view()),
url(r'^(?P<slug>[\w-]+)/edit/$', views.UpdateView.as_view(), name='edit'),
url(r'^vote/(?P<id>[0-9]+)/$', views.vote_handler, name='vote_handler'),
]
I've no idea why this isn't working. It works fine when I hardcode the url as follows:
<form action="/vote/{{instance.id}}/" method="POST" id="upvote_form_post">
I have absolutely no idea why instance.id or instance.get_id is evaluating to a empty string.Does anyone have any idea about this?