Set initial value for customer dropdown

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

View File

@ -97,6 +97,15 @@ class ComputerCreateFromCustomerView(LoginRequiredMixin, CreateView):
kwargs.update({'user': self.request.user})
return kwargs
def get_initial(self):
"""
Set the customer dropdown to the customer from the previews view.
"""
customer = get_object_or_404(Customer, id=self.kwargs.get('pk'))
return {
'customer': customer,
}
class ComputerUpdateView(LoginRequiredMixin, UpdateView):
model = Computer