Answers for "using slug or .. instead of pk in django"

-1

using slug or .. instead of pk in django

from django.shortcuts import get_object_or_404
class TicketDetail(DetailView):
    model = Ticket

    def get_object(self, queryset=None):
        return get_object_or_404(Ticket.objects.all(),uuid=self.kwargs.get("uuid"))
Posted by: Guest on May-01-2021

Browse Popular Code Answers by Language