Get single record on Django Rest Framework based on id
<p>I am getting the following response from my REST API at <a href="http://127.0.0.1:8000/api/category/" rel="nofollow">http://127.0.0.1:8000/api/category/</a>:</p>

<pre><code>[
    {
        "id": "17442811-3217-4b67-8c2c-c4ab762460d6",
        "title": "Hair and Beauty"
    },
    {
        "id": "18a136b5-3dc4-4a98-97b8-9604c9df88a8",
        "title": "Plumbing"
    },
    {
        "id": "2f029642-0df0-4ceb-9058-d7485a91bfc6",
        "title": "Personal Training"
    }
]
</code></pre>

<p>If I wanted to access, a single record, I presume that I would need to go to <a href="http://127.0.0.1:8000/api/category/17442811-3217-4b67-8c2c-c4ab762460d6" rel="nofollow">http://127.0.0.1:8000/api/category/17442811-3217-4b67-8c2c-c4ab762460d6</a> to access:</p>

<pre><code>[
    {
        "id": "17442811-3217-4b67-8c2c-c4ab762460d6",
        "title": "Hair and Beauty"
    }
]
</code></pre>

<p>However, when I attempt this, it returns all of the records. How can I resolve this? This is my code so far:</p>

<p><strong>urls.py</strong></p>

<pre><code>urlpatterns = [
    url(r'^category/', views.CategoryList.as_view(), name="category_list"),
    url(r'^category/?(?P&lt;pk&gt;[^/]+)/$', views.CategoryDetail.as_view(), name="category_detail")
]
</code></pre>

<p><strong>views.py</strong></p>

<pre><code>class CategoryList(generics.ListAPIView):
    """
    List or create a Category
    HTTP: GET
    """
    queryset = Category.objects.all()
    serializer_class = CategorySerializer


class CategoryDetail(generics.RetrieveUpdateDestroyAPIView):
    """
    List one Category
    """
    serializer_class = CategorySerializer
</code></pre>

<p><strong>serializers.py</strong></p>

<pre><code>class CategorySerializer(serializers.ModelSerializer):
    """
    Class to serialize Category objects
    """
    class Meta:
        model = Category
        fields = '__all__'
        read_only_fields = ('id')
</code></pre>

<p><strong>models.py</strong></p>

<pre><code>class Category(models.Model):
    """
    Category model
    """
    id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
    title = models.CharField(max_length=255)

    def __str__(self):
        return "%s" % (self.title)
</code></pre>