1👍
✅
The same way you get any URL parameters in a class-based view:
self.modelname = self.kwargs['modelname']
But you absolutely can’t do this in __init__
. That method is called well before any request is present, and generally should not be overridden in a CBV. You should probably be doing this in get_context_data
.
Source:stackexchange.com