you can get that slug value from kwargs

def get(self, request, *args, **kwargs):
        slug = self.kwargs.get("slug")

also if you like to pass it in the context you can override get_context_data

refer: https://ccbv.co.uk/
to know more about class based views you can refer to this playlist from
video number 36
https://www.youtube.com/playlist?list=PLEsfXFp6DpzTD1BD1aWNxS2Ep06vIkaeW

On Fri, 19 Nov 2021 at 20:41, Perry Bates <perryboaten...@gmail.com> wrote:

> You can use the DetailListView from generic views.
> Pass in the template name, form class, and query(which in this case takes
> in the slug to query the db)
>
>
> On Mon, Nov 15, 2021, 21:27 Aadil Rashid <aadil10121...@gmail.com> wrote:
>
>> Hello my dear Friends, I have a question regarding Class Based Views.
>>
>> If we have a url e.g,
>> path('item/<str:slug>/',  views.funView)
>>
>> We can handle it in  Function Based Views,
>> By simply
>> def funView(request, slug) :
>>        #logic
>>        return render(request, "tempName")
>>
>>
>> We can even pass this slug as a context in this template,
>>
>>
>> My question is how can we achieve this by using class Based Views.
>>
>>
>> Thanks in advance.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAAYXZx_Sn2BBhPWZXi_zEECN-x7wu9sDQJfYeVH31oHhemptpQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAYXZx_Sn2BBhPWZXi_zEECN-x7wu9sDQJfYeVH31oHhemptpQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANMtYSTrHPFaGsmPqp8w6PhPUbxTiU_u8qxvqLQj%2BoJ3O_eZdA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANMtYSTrHPFaGsmPqp8w6PhPUbxTiU_u8qxvqLQj%2BoJ3O_eZdA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVHoOSiEYnr3-7_rrfdo%3DGymGBRVwuc54fd_a6Y%3DC_C%3DBw%40mail.gmail.com.

Reply via email to