title: Django how to use generic view with UUID instead of PK
body: <p>I'm trying to access a url that's like </p>
  
  <p>127.0.0.1:8000/posti/qNwEXBxXQdGI4KlQfoHWOA</p>
  
  <p>However I can't resolve that smalluuid.</p>
  
  <p>This is the error:</p>
  
  <blockquote>
    <p>NoReverseMatch at /posti/ Reverse for 'detail' with arguments
    '(SmallUUID('qNwEXBxXQdGI4KlQfoHWOA'),)' not found. 1 pattern(s)
    tried: ['posti/(?P[0-9a-fA-F-]+)/$']</p>
  </blockquote>
  
  <p>Django has issues trying to resolve it in another view that has a string like this:</p>
  
  <pre><code>from . import views
  from django.conf.urls import url
  
  
  app_name = 'posti'
  
  urlpatterns = [
      url(r'^$', views.IndexView.as_view(), name='index'),
      url(r'^(?P&lt;slug&gt;[0-9a-fA-F-]+)/$', views.DetailView.as_view(), name='detail'),
  </code></pre>
  
  <p>My DetailView is this one:</p>
  
  <pre><code>class DetailView(generic.DetailView):
      model = Post
      template_name = 'posti/detail.html'
      slug_field = 'uuid'
  
  
  
      def get_queryset(self):
          """
          Excludes any questions that aren't published yet.
          """
          return Post.objects.all()
  </code></pre>
  
  <p>I tried rewriting get_object but it didn't do anything. I don't understand if the regex is wrong or if my view has something wrong.</p>
  
  <p>EDIT:</p>
  
  <p>My template on index raised the error above and it had the following code:</p>
  
  <pre><code>{% if posti_list != null %}
      &lt;ul&gt;
      {% for post in posti_list %}
          &lt;li&gt;&lt;a href="{% url 'posti:detail' post.uuid %}"&gt;{{ post.title }}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
      &lt;/ul&gt;
  {% else %}
      &lt;p&gt;No posts are available.&lt;/p&gt;
  {% endif %}
  </code></pre>
  
  <p>I added <code>slug_url_kwarg = 'uuid'</code> to the DetailView class and now it works BUT now I have a </p>
  
  <blockquote>
    <p>AttributeError at /posti/qNwEXBxXQdGI4KlQfoHWOA/ Generic detail view
    DetailView must be called with either an object pk or a slug.</p>
  </blockquote>
  
  <p>When I try to access the specific post.</p>