Python: NoReverseMatch error: Reverse for 'detail' with arguments '(UUID)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['']in django
<p>I have created a model 'Post' in which I use UUID rather than Django inbuilt autogenerated ID. In 'Post' model I define a def get_absolute_url so that i can keep it in my template. When i am trying to get the Deal page, it is raising an error : NoReverseMatch at /deal/
Reverse for 'detail' with arguments '(UUID('086d177f-9071-4548-b5db-1d329078853e'),)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['deal/(?P\d+)/$']. I would appreciate helping me in solve this.</p>

<p>Here's my code:</p>

<p>Models.py:</p>

<pre><code>class Post(models.Model):
    post_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
    from1 = models.CharField(max_length=20)

    def __str__(self):
        return self.post_id

    def get_absolute_url(self):
        return reverse("detail", args=(self.post_id))
</code></pre>

<p>urls.py:</p>

<pre><code>url(r'^deal/$', views.deal, name='deal'),
url(r'^deal/(?P&lt;post_id&gt;\d+)/$', views.post_detail, name='detail'),
</code></pre>

<p>Views.py:</p>

<pre><code>def deal(request):
    queryset_list = Post.objects.active() #.order_by("-timestamp")
    if request.user.is_staff or request.user.is_superuser:
        queryset_list = Post.objects.all()
    context = {
        "object_list": queryset_list, 
        "post_id": "List",
    }
    return render(request, 'before_login/deal.html', context)

def post_detail(request, post_id=None):  
    instance = get_object_or_404(Post, post_id=post_id)
    if instance.date &gt; timezone.now().date():
        if not request.user.is_staff or not request.user.is_superuser:
            raise Http404
    share_string = quote_plus(instance.Material_Type)
    context = {
        "from1": instance.from1,
        "instance": instance,
        "share_string": share_string
    }
    return render(request, "loggedin_load/post_detail.html", context)
</code></pre>

<p>deal.html:</p>

<pre><code>{% for obj in object_list %}
    &lt;tr&gt;
      &lt;td scope="row"&gt;{{obj.post_id}}&lt;/td&gt;
      &lt;td&gt; &lt;a href='{{ obj.get_absolute_url }}'&gt;{{ obj.from1 }}&lt;/a&gt;&lt;br/&gt;&lt;/td&gt;
      &lt;td&gt;{{obj.user}}&lt;/td&gt;
    &lt;/tr&gt;
{% endfor %}
</code></pre>