Answer the question
In order to leave comments, you need to log in
How to get value from GET request in django controller?
I have this request
path('file/<int:event>', CreateFileView.as_view(), name='add_file')
class CreateFileView(CreateView):
model = FileFeedbackEventToSubscriber
form_class = FileFieldForm
template_name = 'file.html'
success_url = reverse_lazy('filefeedback_events_home')
def get_context_data(self, **kwargs):
context = super(CreateFileView, self).get_context_data(**kwargs)
context['current_user'] = self.request.user
return context
Answer the question
In order to leave comments, you need to log in
Get the value from the kwargs dictionary stored by url and get parameters. And before using it in any methods, you need to pass it (**kwargs), but since it already exists in the get_context_data method, you just have to do this: (here you just pass the parameter name). self.kwargs['event']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question