pass various variables to CreateComputerForm

This commit is contained in:
Andreas Zweili 2020-02-29 11:46:18 +01:00
parent 473cbf8919
commit fabdfe4c9b
1 changed files with 9 additions and 0 deletions

View File

@ -88,6 +88,15 @@ class ComputerCreateFromCustomerView(LoginRequiredMixin, CreateView):
def get_success_url(self):
return reverse('computer_update', args=(self.object.pk,))
def get_form_kwargs(self):
"""
Pass the URL variables and the request user to the form.
"""
kwargs = super(ComputerCreateFromCustomerView, self).get_form_kwargs()
kwargs.update(self.kwargs)
kwargs.update({'user': self.request.user})
return kwargs
class ComputerUpdateView(LoginRequiredMixin, UpdateView):
model = Computer