diff options
Diffstat (limited to '')
-rw-r--r-- | pyblackbird_cc/resources/forms.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pyblackbird_cc/resources/forms.py b/pyblackbird_cc/resources/forms.py index 35c5034..1b82ab7 100644 --- a/pyblackbird_cc/resources/forms.py +++ b/pyblackbird_cc/resources/forms.py @@ -1,4 +1,5 @@ import logging +from typing import List, Tuple import magic from crispy_forms.helper import FormHelper @@ -18,6 +19,14 @@ ALLOWED_THUMBNAILS = 5 ALLOWED_PDFS = 20 +def _create_choices_tuple() -> List[Tuple[str, str]]: + qs_lst = list(ResourceCategory.objects.values_list('name', flat=True)) + res = [] + for x in qs_lst: + res.append((x, x)) + return res + + class ResourceCreateForm(forms.Form): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -75,8 +84,8 @@ class ResourceCreateForm(forms.Form): "searches. It's a good idea to limit the number of subjects you select " "to one or two to make your resource easier to find.", ) - additional_resource_category = forms.ModelChoiceField( - queryset=ResourceCategory.objects.all(), + additional_resource_category = forms.MultipleChoiceField( + choices=_create_choices_tuple(), required=False, ) pdf_files = forms.FileField( |