title: Using Slugify in Django urls
body: <p>I'm trying to create SEO friendly urls where all spaces are replaced with a hyphen.</p>
  
  <p>This is how I'm 'slugifying' the URL by using slugify in Django templates</p>
  
  <pre><code>&lt;a href="{% url 'dj' dj_name=dj.name|slugify %}"&gt;
  </code></pre>
  
  <p>Here is my urls.py</p>
  
  <pre><code>url(r'^top100/(?P&lt;dj_name&gt;[a-zA-Z0-9 \'&amp;-]+)/$', views.dj, name='dj')
  </code></pre>
  
  <p>This is my view</p>
  
  <pre><code>def dj(request, dj_name):
      dj = DJ.objects.get(name=dj_name)
      dj_song_list = Song.objects.filter(artist=dj, duplicate=False).order_by('-votes', '-release_date')
      return render(request, 'hunt/dj.html', {'dj_song_list': dj_song_list, 'dj':dj}
  </code></pre>
  
  <p>Now the <code>%20</code> in the urls has changed to a <code>-</code> but I get the error <code>DJ matching query does not exist.</code></p>
  
  <p>Also this ignores <code>&amp;</code> in the DJ name. For example it changes the url for the DJ <code>Above &amp; Beyond</code> to <code>www.example.com/top100/above-beyond</code></p>