Answers for "class based detail view year permalink"

0

class based detail view year permalink

from django.shortcuts import get_object_or_404

class MagDetail(DetailView):
    model = Mag

    def get_object(self):

        obj = get_object_or_404(
            self.model, 
            pk=self.kwargs['pk'], 
            pub_date__year=self.kwargs['year'])

        return obj
Posted by: Guest on October-16-2020

Code answers related to "class based detail view year permalink"

Browse Popular Code Answers by Language