Updating context data in FormView form_valid method?

前端 未结 4 1652
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 01:43

I have a class QuestionView which is derived from the FormView class. Here is a code snippet to explain my problem:

class QuestionV         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 02:35

    Maybe you can use this approach:

    class SomeView(View):
    
        def post(self, request):
            my_form = MyForm(request.POST)
            if my_form.is_valid():
                context['foo'] = 'bar'
    
            return render(request, 'valid/path.html', context)
    

提交回复
热议问题