title: django group subcategory with category slug
body: <p>Trying to make a linkdirectory page with categories and subcategories, have the following so far, problem is that i can't get the category as a link</p>
  
  <pre><code>models.py
  class Category(models.Model):
  """Category"""
  name = models.CharField(max_length=50)
  slug = models.SlugField()
  
  def save(self, *args, **kwargs):
  
                  #self.slug = slugify(self.name)
          self.slug = slugify(self.name)
          super(Category, self).save(*args, **kwargs)
  def __unicode__(self):
  return self.name
  
  
  class SubCategory(models.Model):
  """Sub Category"""
  category = models.ForeignKey(Category)
  name = models.CharField(max_length=50)
  slug = models.SlugField()
  
  def save(self, *args, **kwargs):
  
          self.slug = slugify(self.name)
          super(SubCategory, self).save(*args, **kwargs)
  
  def __unicode__(self):
  return self.name    
  </code></pre>
  
  <p>and</p>
  
  <pre><code>views.py
  @require_GET
  def links(request):
  """Linkdirectory Page"""
  categories = Category.objects.all()
  subcategories = SubCategory.objects.all()
  return render(request, 'links.html', {'categories':         categories,             'subcategories': subcategories,})
  </code></pre>
  
  <p>in order to group the subcategories by category i used the following in </p>
  
  <pre><code>{% regroup subcategories|dictsort:"category_id" by category as     categories_list %}
  
  &lt;ul&gt;
  {% for categories in categories_list %}
  &lt;li&gt;{{ categories.grouper }}
             &lt;li&gt; &lt;a href="/links/{{ categories.slug }}"&gt;{{ categories.name     }}&lt;/a&gt;&lt;/li&gt;
  &lt;ul&gt;
      {% for item in categories.list %}
              &lt;li&gt;&lt;a href="/links/{{ item.slug }}"&gt;{{ item.name }}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  &lt;/li&gt;
  {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>This all works nicely grouping the subcats together</p>
  
  <p>CAT1
  --subcatLINK1
  --subcatLINK2</p>
  
  <p>but what i would like to have is</p>
  
  <p>CATLINK1
  --subcatLINK1
  --subcatLINK2</p>
  
  <p>Not sure how and if its possible to replace the grouper string with a custom link as like the subcategory link or if i'm going the right way around this</p>
  
  <p>Edited, adding Bakkals approach below:
  EDIT AGAIN ;) nevermind, i had to update the naming scheme aswell obviously, below code is the working version.
  trying to use category.subcategory_set.all as suggested by Bakkal</p>
  
  <pre><code>{% for category in categories %}
  &lt;ul&gt;
  &lt;li&gt;&lt;a href="/links/{{ category.slug }}"&gt;{{ category.name }}&lt;/a&gt;
  {% for subcategory in category.subcategory_set.all %}
  &lt;ul&gt;
              &lt;li&gt;&lt;a href="/links/{{ subcategory.slug }}"&gt;{{     subcategory.name }}&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
      {% endfor %}
  &lt;/li&gt;
  &lt;/ul&gt;
  {% endfor %}
  &lt;/li&gt;
  &lt;/ul&gt;
  {% endfor %}
  </code></pre>