Reputation: 4517
My code is as shown below:
class CharMaxlength25Field(models.Field):
def db_type(self, connection):
return 'enum(android,ios)'
class search(models.Model):
class Meta:
db_table = 'search'
city_name = CharMaxlength25Field()
Through this code, I am trying to create enum
field in mysql. Now when I try to run this schema with python manage.py makemigrations
step,I get the following error:
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'android,ios) NULL' at line 1")
Upvotes: 0
Views: 195
Reputation: 47364
Try to add quotes:
class CharMaxlength25Field(models.Field):
def db_type(self, connection):
return 'enum("android","ios")'
Upvotes: 1