title: NoReverseMatch at / Reverse for 'product_list_by_category' with keyword arguments '{'slug': 'legume'}'
body: <p>Everytime I run my django project, I get this error <code>NoReverseMatch at /
  Reverse for 'product_list_by_category' with keyword arguments '{'slug': 'legume'}'</code>. I want to list my products and to be honest, I don't even know what the problem is.</p>
  
  <p>Full trace: django.urls.exceptions.NoReverseMatch: Reverse for 'product_list_by_category' with keyword arguments '{'slug': 'legume'}' not found. 1 pattern(s) tried: ['(?P\w+)/$']
  [29/Nov/2017 22:18:22] "GET / HTTP/1.1" 500 180670</p>
  
  <p>My main <strong>URLS</strong></p>
  
  <pre><code>from django.conf.urls import url, include
  from django.contrib import admin
  from django.conf import settings
  from  django.conf.urls.static import static
  
  urlpatterns = [
      url(r'^admin/', admin.site.urls),
      url(r'^', include('shop.urls', namespace = 'shop'))
  ]
  
  if settings.DEBUG:
      urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
  </code></pre>
  
  <p>My <strong>Models.py</strong> page</p>
  
  <pre><code>from django.db import models
  from django.core.urlresolvers import reverse
  
  # Create your models here.
  
  class Category(models.Model):
      name = models.CharField(max_length=120 , db_index = True)
      slug = models.SlugField(max_length=200 , db_index = True , unique= True)
  
      class Meta:
          ordering = ('name',)
          verbose_name = 'category'
          verbose_name_plural = 'categories'
  
      def __str__(self):
          return self.name
  
      def get_absolute_url(self):
          return  reverse('shop:product_list_by_category', kwargs={'slug':self.slug})
  
  
  class Product(models.Model):
      category = models.ForeignKey(Category, related_name='products')
      name = models.CharField(max_length=200, db_index = True)
      slug = models.SlugField(max_length=200, db_index = True)
      image = models.ImageField(upload_to='products/%y/%m/%d', blank=True)
      description = models.TextField(blank = True)
      price = models.DecimalField(max_digits=10, decimal_places=2)
      stock = models.PositiveIntegerField()
      available = models.BooleanField(default=True)
      created = models.DateTimeField(auto_now_add=True)
      updated = models.DateTimeField(auto_now= True)
  
      class Meta:
          ordering = ('-created',)
          index_together = (('id','slug'),)
  
      def __str__(self):
          return self.name
  
      def get_absolute_url(self):
          return reverse('shop:product_detail', args=[self.id, self.slug])
  </code></pre>
  
  <p>My app <strong>URLS</strong></p>
  
  <pre><code>from django.conf.urls import url
  from . import views
  
  urlpatterns = [
      url(r'^$', views.product_list, name='product_list'),
      url(r'^(?P&lt;category_slug&gt;\w+)/$', views.product_list, name='product_list_by_category'),
      url(r'^(?P&lt;id&gt;\d+)/(?P&lt;slug&gt;[-\w]+)/$', views.product_detail, name='product_detail'),
  ]
  </code></pre>
  
  <p>Here is my <strong>Base.HTML</strong></p>
  
  <pre><code>{% load static %}
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;{% block title %}AgroShop{% endblock %}&lt;/title&gt;
      &lt;link rel = stylesheet href = '{% static "css/base.css" %}'&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="header"&gt;
          &lt;a href="/" class = "logo"&gt;AgroShop&lt;/a&gt;
      &lt;/div&gt;
  
      &lt;div class="subheader"&gt;
          &lt;div class="cart"&gt;
              {% with total_items=cart|length %}
                  {% if cart|length &gt; 0 %}
                      Your cart :
                      &lt;a href="{% url "cart:cart_detail" %}"&gt;
                          {{ total_items }} item{{ total_items|pluralize }}
                      &lt;/a&gt;
                  {% else %}
                      Your cart is empty.
                  {% endif %}
              {% endwith %}
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div id="content"&gt;
          {% block content %}
          {% endblock %}
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>List.HTML</strong></p>
  
  <pre><code>{% extends 'shop/base.html' %}
  {% load static %}
  
  {% block title %}
      {% if category %}{{ category.name }}{% else %}{{ Products }}{% endif %}
  {% endblock %}
  
  {% block content %}
      &lt;div class="sidebar"&gt;
          &lt;h3&gt;Categories:&lt;/h3&gt;
          &lt;ul&gt;
              &lt;li {% if not category %} class="selected"&gt;{% endif %}&gt;
                  &lt;a href="{% url 'shop:product_list' %}"&gt;All&lt;/a&gt;
              &lt;/li&gt;
          {% for c in categories %}
              &lt;li {% if category.slug == c.slug %} class = 'selected{% endif %}'&gt;
                  &lt;a href="{{ c.get_absolute_url }}"&gt;{{ c.name }}&lt;/a&gt;
              &lt;/li&gt;
          {% endfor %}
          &lt;/ul&gt;
      &lt;/div&gt;
  
      &lt;div id="main" class="product-list"&gt;
          &lt;h1&gt;{% if category %}{{ category.name }}{% else %}Products{% endif %}&lt;/h1&gt;
          {% for product in products %}
              &lt;div class="item"&gt;
                  &lt;a href="{{ product.get_absolute_url }}"&gt;
                      &lt;img src="{% if product.image %}{{ product.image.url }}{% else %}{% static 'img/dirig.jpg' %}{% endif %}" alt=""&gt;
                  &lt;/a&gt;
                  &lt;a href="{{ product.get_absolute_url }}"&gt;{{ product.name }}&lt;/a&gt;&lt;br&gt;
                  {{ product.price }}
              &lt;/div&gt;
          {% endfor %}
      &lt;/div&gt;
  {% endblock %}
  </code></pre>