0

У меня есть вот такой запрос

path('file/<int:event>', CreateFileView.as_view(), name='add_file') # new

Нужно получить event_id отсюда во view

View имеет вид:

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

Что мне куда или как нужно дописать, чтоб это работало? Либо есть еще какой-то способ получить значение текущего объекта без запроса сразу из view?

1 ответ 1

6
self.kwargs['event']

все просто

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.