title: How can I apply my form to multiple templates in django
body: <p>I am creating a blog site where users can post articles on the home page which can then also be commented on using a form. These posts can also be viewed elsewhere on the site, under search results and on user profiles for example. What I am trying to do is allow users to comment on the posts anywhere that they appear. For this I am using an inclusion tag for my comment form which looks like this:</p>
  <pre><code>@register.inclusion_tag('posts/comment.html')
  def comment_create_and_list_view(request):
      profile = Profile.objects.get(user=request.user)
      c_form = CommentModelForm()
  
      if 'submit_c_form' in request.POST:
          c_form = CommentModelForm(request.POST)
          if c_form.is_valid():
              instance = c_form.save(commit=False)
              instance.user = profile
              instance.post = Post.objects.get(id=request.POST.get('post_id'))
              instance.save()
              c_form = CommentModelForm()
  
      context = {
          'profile': profile,
          'c_form': c_form,
      }
  
      return context
  </code></pre>
  <p>And is registered to my urls like this:</p>
  <pre><code>from django.urls import path
  from .templatetags.custom_tags import comment_create_and_list_view
  from .views import *
  
  app_name = 'posts'
  
  urlpatterns = [
      path('comment/&lt;int:pk&gt;/', comment_create_and_list_view, name='comment'),
  ]
  </code></pre>
  <p>My form looks like this:</p>
  <pre><code>class CommentModelForm(forms.ModelForm):
      class Meta:
          model = Comment
          fields = ('body',)
  </code></pre>
  <p>comment.html looks like this:</p>
  <pre><code>&lt;form action=&quot;{% url 'posts:comment' post.id %}&quot; method=&quot;post&quot;&gt;
      {% csrf_token %}
      &lt;input type=&quot;hidden&quot; name=&quot;post_id&quot; value={{ post.id }}&gt;
      {{ c_form }}
      &lt;button type=&quot;submit&quot; name=&quot;submit_c_form&quot;&gt;Send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>And I am importing the inclusion tag to my base.html file using <code>{% comment_create_and_list_view request %}</code></p>
  <p>Upon attempting to load the page I receive the NoReverseMatch at / error:</p>
  <p><code>Reverse for 'comment' with arguments '('',)' not found. 1 pattern(s) tried: ['comment/(?P&lt;pk&gt;[0-9]+)/$']</code></p>
  <p>Been googling this for hours and can't understand where I am going wrong...</p>