Django Convert ID to slug : <p>Im new to django and wanted to <strong>convert id/pk to slug</strong>, I wanted to make <strong>url to be friendly or easy to understand</strong></p>

<p>Wanted to make url  <code>http://127.0.0.1:8000/1/</code> to <code>http://127.0.0.1:8000/hello/</code></p>

<p>Model.py</p>

<pre><code>class Post(models.Model):
    title=models.CharField(max_length=200)
    description=models.TextField(max_length=10000)
    pub_date=models.DateTimeField(auto_now_add=True)
    comments=models.CharField(max_length=200, blank=True)
    slug = models.SlugField(max_length=40, unique=True)

    def __unicode__(self):
        return self.title

    def description_as_list(self):
        return self.description.split('\n')
</code></pre>

<p>admin.py</p>

<pre><code>class PostAdmin(admin.ModelAdmin):
    list_display=['title','description']
    prepopulated_fields = {'slug': ('title',)}

    class Meta:
        model = Post

admin.site.register(Post,PostAdmin)
</code></pre>

<p>urls.py</p>

<pre><code>urlpatterns = [

    url(r'^$', views.PostListView.as_view(),name='home'),
    url(r'^(?P&lt;slug&gt;[\w-]+)/$', views.detail, name='detail'),
]
</code></pre>

<p>views.py</p>

<pre><code>class PostListView(ListView):
    model = Post
    template_name = 'blog_post.html'
    queryset = Post.objects.order_by('-pub_date')
    paginate_by = 2

def detail(request, id):
    posts = Post.objects.get(id=id)
    return render(request, "blog_detail.html", {'posts': posts,})
</code></pre>

<p>Templates</p>

<pre><code>{% for threads in object_list  %}
    &lt;p class="blog-post-title"&gt;&lt;a href="{% url 'detail' slug=threads.id %}"&gt;{{ threads.title }}&lt;/a&gt;&lt;/p&gt;
    &lt;hr /&gt;
{% endfor %}
</code></pre>

<p>Following <strong>error</strong> is obtained by doing so...What more changes to be 
<a href="https://i.stack.imgur.com/1Dh8g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Dh8g.png" alt="enter image description here"></a></p>

<p>Any help is appreciated to make url readable. Thanks in davance</p>
