title: Reverse for 'post_share' with arguments '('',)' not found. 2 pattern(s) tried: ['blog\\/(?P<post_id>[0-9]+)\\/share\\/$', 'blog\\/post_share\\/$']
body: <p>Before, you guys give me that "use the search tools" kind of speech. Yeah, I already did it, and to no avail. Anyways, I have been scratching my head for the last two days trying to figure out why I keep getting this error" Reverse for 'post_share' with arguments '('',)' not found. 2 pattern(s) tried: ['blog\/(?P[0-9]+)\/share\/$', 'blog\/post_share\/$']"</p>
  
  <p>I am using Django 2 and I am reading the book Code for Django by Example book by Antonio Mele.</p>
  
  <h2>Forms.py</h2>
  
  <pre><code>class EmailPostForm(forms.Form):
  name = forms.CharField(max_length = 30)
  email = forms.EmailField()
  to = forms.EmailField()
  comments = forms.CharField(required = False, widget = forms.Textarea)
  </code></pre>
  
  <h2>Views.py</h2>
  
  <pre><code>def post_share(request, post_id):
      post = get_object_or_404(Post, id = post_id, status = 'published')
      sent = False
  
      if request.method == 'POST':
          form = EmailPostForm(request, POST)
  
          if form.is_valid():
              cd = form.cleaned_data
              post_url = request.build_absolute_uri(post.get_absolute_url())
              subject = '{} ({}) recommends you reading "{}"'.format(cd['name'], cd['email'], post.title)
              message = 'Read "{}" at {}\n\n{}\'s comments: {}'.format(post.title, post_url, cd['name'], cd['comments'])
              send_mail(subject, message, 'sample@gmail.com', [cd['to']])
              sent = True
      else:
          form = EmailPostForm()
      return render(request, 'blogg/shared.html', {
                                              'post': post,
                                              'form': form,
                                              'sent':sent
                                              })
  </code></pre>
  
  <h2>urls.py</h2>
  
  <pre><code>app_name = 'blog'
  
  urlpatterns = [
  
      path('post_list', views.post_list, name = 'post_list'),
      path('post_detail/&lt;int:year&gt;/&lt;int:month&gt;/&lt;int:day&gt;/&lt;str:post&gt;', views.post_detail, name = 'post_detail'),
      path('post_share/', views.post_share, name = 'post_share'),
      # re_path(r'^(?P&lt;post_id&gt;\d+)/share/$', views.post_share, name='post_share'),
      path('&lt;int:post_id&gt;/share/', views.post_share, name='post_share'),
  ]
  </code></pre>
  
  <h2>details</h2>
  
  <pre><code>{% extends 'blogg/base.html'%}
  
  {% block title %} {{ post.title }} {% endblock %}
  
  {% block content %}
      &lt;h1&gt; {{ post.title }}&lt;/h1&gt;
      &lt;p&gt;Published {{ post.publish }} by {{ post.author }}&lt;/p&gt;
      {{ post.body|linebreaks }}
      &lt;p&gt;
          &lt;a href="{% url 'blog:post_share' post.id %}"&gt; Share Post &lt;/a&gt;
      &lt;/p&gt;
  {% endblock %}
  </code></pre>
  
  <h2>Error</h2>
  
  <pre><code>NoReverseMatch at /blog/post_detail/2018/04/24/simple-test
  
  Reverse for 'post_share' with arguments '('',)' not found. 2 pattern(s) tried: ['blog\\/(?P&lt;post_id&gt;[0-9]+)\\/share\\/$', 'blog\\/post_share\\/$']
  
  Request Method:     GET
  Request URL:    http://127.0.0.1:8000/blog/post_detail/2018/04/24/simple-test
  Django Version:     2.0.4
  Exception Type:     NoReverseMatch
  Exception Value:    
  
  Reverse for 'post_share' with arguments '('',)' not found. 2 pattern(s) tried: ['blog\\/(?P&lt;post_id&gt;[0-9]+)\\/share\\/$', 'blog\\/post_share\\/$']
  
  Exception Location:     C:\Dev\blog\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 632
  Python Executable:  C:\Dev\blog\Scripts\python.exe
  Python Version:     3.6.4
  Python Path:    
  
  ['C:\\Dev\\blog\\src\\mysite',
   'C:\\Dev\\blog\\Scripts\\python36.zip',
   'C:\\Dev\\blog\\DLLs',
   'C:\\Dev\\blog\\lib',
   'C:\\Dev\\blog\\Scripts',
   'c:\\program files (x86)\\python36-32\\Lib',
   'c:\\program files (x86)\\python36-32\\DLLs',
   'C:\\Dev\\blog',
   'C:\\Dev\\blog\\lib\\site-packages']
  
  Server time:    Tue, 24 Apr 2018 12:40:59 +0000`
  </code></pre>