title: Am I writing my template tag urls correctly?
body: <p>using Django 2 I am trying to add a shopping cart app to my django project. I am getting this error message: Reverse for 'add_cart' with arguments '('',)' not found. 1 pattern(s) tried: ['cart/add/(?P[0-9]+)/$']</p>
  
  <p>From my understanding and doing some research I think my problem is that I am not inputting the correct urls in the template tags to link to my views. But I am only 4 weeks in to Django and am a bit lost.</p>
  
  <p>I have tried changing the "{% url 'cart_remove' cart_item.product.id %}" and "{% url 'cart_add' cart_item.product.id %}" tags.</p>
  
  <p>I have tried adjusting the app and project level urls.py. </p>
  
  <p>I have tried to change the base.html, cart.html</p>
  
  <p>I have tried changing the views and have read through every file a number of times trying to spot an error or typo.</p>
  
  <p>I have been changing things around for about 5 hours now but nothing seems to work. as I said I think it is a problem with my template tags. I reckon I am confused and am trying to link the wrong thing. </p>
  
  <p>cart.html</p>
  
  <pre class="lang-py prettyprint-override"><code>{% for cart_item in cart_items %}
                  &lt;tr&gt;
                      &lt;td&gt;{{cart_item.product.name}}&lt;/td&gt;
                      &lt;td&gt;{{cart_item.product.brand}}&lt;/td&gt;
                      &lt;td&gt;{{cart_item.product.description}}&lt;/td&gt;
                      &lt;td&gt;€{{cart_item.product.price}}&lt;/td&gt;
                      &lt;td&gt;{{cart_item.sub_total}}&lt;/td&gt;
                      &lt;td&gt;{{cart_item.quantity}}&lt;/td&gt;
                      &lt;td&gt;&lt;a href="{% url 'cart_remove' cart_item.product.id%}"&gt;  
                          &lt;span class="glyphicon glyphicon-minus-sign"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;a href="{% url 'add_cart' cart_item.product.id %}"&gt;  
                          &lt;span class="glyphicon glyphicon-plus-sign"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  {% endfor %}
  </code></pre>
  
  <p>add_cart function in cart/views.py</p>
  
  <pre class="lang-py prettyprint-override"><code>def add_cart(request, product_id):
      product = Product.objects.get(id=product_id)
      try:
          cart = Cart.objects.get(cart_id=_cart_id(request))
      except Cart.DoesNotExist:
          cart = Cart.objects.create(
              cart_id = _cart_id(request)
          )
          cart.save()
      try:
          cart_item = CartItem.objects.get(product=product, cart=cart)
          if cart_item.quantity &lt; cart_item.product.stock:
              cart_item.quantity += 1
              cart_item.save()
          else:
              messages.add_message(request, messages.INFO,
               'Sorry, no more of this item available')
      except CartItem.DoesNotExist:
          cart_item = CartItem.objects.create(
              product = product,
              quantity = 1,
              cart = cart
          )
          cart_item.save()
      return redirect('cart_detail')
  </code></pre>
  
  <p>cart/urls.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from django.urls import path
  from . import views
  
  urlpatterns = [
      path('add/&lt;int:product_id&gt;/', views.add_cart, name='add_cart'),
      path('', views.cart_detail, name='cart_detail'),
      path('remove/&lt;int:product_id&gt;/', views.cart_remove, name='cart_remove'),
      path('full_remove/', views.full_remove, name='full_remove'),
  ]
  </code></pre>
  
  <p>Template paths</p>
  
  <pre><code>'DIRS': [os.path.join(BASE_DIR, 'templates'),
           os.path.join(BASE_DIR, 'shop', 'templates/'),
           os.path.join(BASE_DIR, 'cart', 'templates/'),],
  </code></pre>
  
  <p>Project level urls.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from django.contrib import admin
  from django.urls import path, include
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('', include('landing.urls')),
      path('shop/', include('shop.urls')),
      path('cart/', include('cart.urls')),   
  ]
  </code></pre>
  
  <p>My expected result is for the landing page to show when i connect to my local server and for the shop.html page to load when I click on the shop link in my nav bar. At the moment I am getting the error: Reverse for 'add_cart' with arguments '('',)' not found. 1 pattern(s) tried: ['cart/add/(?P[0-9]+)/$']</p>