From d9b9e908c3e49d27bef347d72a5fce02302e1de9 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 10 Sep 2024 20:25:14 +0100 Subject: Fix bug in subcategories choices func --- pyblackbird_cc/resources/forms.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyblackbird_cc/resources/forms.py b/pyblackbird_cc/resources/forms.py index 5327def..f046969 100644 --- a/pyblackbird_cc/resources/forms.py +++ b/pyblackbird_cc/resources/forms.py @@ -25,7 +25,9 @@ ALLOWED_PDFS = 20 def _create_choices_tuple() -> list[tuple[str, str]]: """Returns a list of tuples containing resource subcategory names.""" - return sorted(list(ResourceSubcategory.objects.values_list("name", flat=True)), key=str) + vals = sorted(ResourceSubcategory.objects.values_list("name", flat=True), key=str) + out = tuple((x, x) for x in vals) + return out class ResourceCreateForm(forms.Form): @@ -34,6 +36,7 @@ class ResourceCreateForm(forms.Form): self.helper = FormHelper(self) self.helper.add_input(Submit("submit", "Submit")) self.fields["subcategories"].choices = _create_choices_tuple() + pass error_css_class = "error" required_css_class = "required" -- cgit v1.2.3