diff --git a/container/views.py b/container/views.py index a1eae54..b57af54 100644 --- a/container/views.py +++ b/container/views.py @@ -27,6 +27,8 @@ class ContainerCreateView(LoginRequiredMixin, generic.CreateView): fields = ['named_id', 'description', 'color', 'container_type'] def form_valid(self, form): + if not form.instance.named_id.startswith('C-'): + form.instance.named_id = 'C-' + form.instance.named_id form.instance.changed_by = self.request.user form.instance.created_by = self.request.user return super().form_valid(form) @@ -53,8 +55,11 @@ class ContainerUpdateView(LoginRequiredMixin, generic.UpdateView): model = Container # template_name = 'container/detail.html' fields = ['named_id', 'description', 'color', 'container_type'] + success_url = "/container/" def form_valid(self, form): + if not form.instance.named_id.startswith('C-'): + form.instance.named_id = 'C-' + form.instance.named_id form.instance.changed_by = self.request.user return super().form_valid(form)