Do not set the style of a TextField to textarea if choices is set because it will be converted to a ChoiceField and it is more appropriate to let this default to a select box

This commit is contained in:
Chris Bailey 2018-09-12 16:53:26 +01:00
parent 5f1f2b1003
commit 7c1510d6ec

View File

@ -88,7 +88,7 @@ def get_field_kwargs(field_name, model_field):
if decimal_places is not None:
kwargs['decimal_places'] = decimal_places
if isinstance(model_field, models.TextField) or (postgres_fields and isinstance(model_field, postgres_fields.JSONField)):
if isinstance(model_field, models.TextField) and not model_field.choices or (postgres_fields and isinstance(model_field, postgres_fields.JSONField)):
kwargs['style'] = {'base_template': 'textarea.html'}
if isinstance(model_field, models.AutoField) or not model_field.editable: