class TypesOfMedical(models.TextChoices):
Hospital = 'Hospital', _('Hospital')
Clinic = 'Clinic', _('Clinic')
Pharmacy = 'Pharmacy', _('Pharmacy')
class Medical(models.Model):
name = models.CharField(max_length=250)
type = models.CharField(
max_length=20,
choices=TypesOfMedical.choices,
default=TypesOfMedical.Hospital,
)
But this set the MySQL table column’s type as varchar(20)
instead of ENUM('Hospital','Clinic','Pharmacy')
- why is this so ?
Wouldn’t SQL search be faster if its an ENUM of n types instead of a text search ? Maybe not, but I feel a MySQL structure is more understandable than text.