mirror of
https://github.com/inventree/InvenTree.git
synced 2026-03-16 09:01:30 +00:00
Add null choice to custom serializer class
This commit is contained in:
@@ -756,6 +756,9 @@ class ContentTypeField(serializers.ChoiceField):
|
||||
(f'{ct.app_label}.{ct.model}', str(ct)) for ct in content_types
|
||||
]
|
||||
|
||||
if kwargs.get('allow_null') or kwargs.get('allow_blank'):
|
||||
kwargs['choices'] = [('', '---------'), *kwargs['choices']]
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def to_representation(self, value):
|
||||
|
||||
@@ -29,6 +29,7 @@ def get_spectacular_settings():
|
||||
'TemplateModelTypeEnum': 'report.models.ReportTemplateBase.ModelChoices',
|
||||
'AttachmentModelTypeEnum': 'common.models.Attachment.ModelChoices',
|
||||
'ParameterModelTypeEnum': 'common.models.Parameter.ModelChoices',
|
||||
'ParameterTemplateModelTypeEnum': 'common.models.ParameterTemplate.ModelChoices',
|
||||
'DataImportSessionModelTypeEnum': 'importer.models.DataImportSession.ModelChoices',
|
||||
# Allauth
|
||||
'UnauthorizedStatus': [[401, 401]],
|
||||
|
||||
Reference in New Issue
Block a user