pass the request user to the ComputerUpdateForm

This commit is contained in:
Andreas Zweili 2020-02-29 12:24:46 +01:00
parent c9e5963c07
commit f10e4f7800
1 changed files with 9 additions and 1 deletions

View File

@ -110,4 +110,12 @@ class ComputerCreateFromCustomerView(LoginRequiredMixin, CreateView):
class ComputerUpdateView(LoginRequiredMixin, UpdateView):
model = Computer
form_class = ComputerUpdateForm
template_name = 'computers/computer_update.html'
template_name = 'computers/computer_update.html'
def get_form_kwargs(self):
"""
Pass the request user to the form.
"""
kwargs = super(ComputerUpdateView, self).get_form_kwargs()
kwargs.update({'user': self.request.user})
return kwargs