I need use column named class. But class is a keyword reserved in python.
models.py:
class Colecao(models.Model):
class = models.CharField(max_length=50,blank=True,verbose_name="Classe")
I need use column named class. But class is a keyword reserved in python.
models.py:
class Colecao(models.Model):
class = models.CharField(max_length=50,blank=True,verbose_name="Classe")
By default, Django will use the field’s name as the name of the database column . in your case class is a reserved keyword in python you cannot use it but you can
customize the database column name for it by using db_column
use it like this :
class Colecao(models.Model):
class_ = models.CharField(max_length=50,blank=True,
db_column='class', verbose_name="Classe")