Django class based views - UpdateView with two model forms - one submit

前端 未结 2 1168
-上瘾入骨i
-上瘾入骨i 2020-12-14 14:05

I have a page with a list of users, and would like to be able to click a link to update their profile. When \'update\' is clicked, I should be able to edit the username, fir

相关标签:
2条回答
  • 2020-12-14 14:21

    Try to quit the self.request.get on get_content_data forms constructors and use the "object" variable. With that get you reinitialize the constructor, more in this link.

    My code:

     context['form'] = self.form_class(instance=self.object)
    
    0 讨论(0)
  • 2020-12-14 14:41

    You should be able to use the "instance" kwarg for the instantiation of the form from an existing model if that's what you need. Example:

    context['form'] = self.form_class(self.request.GET, instance=request.user)
    
    0 讨论(0)
提交回复
热议问题