我有一个模特:
class Users_data (models.Model):
first_name_user = models.CharField(max_length=45, verbose_name="")
e_mail = models.EmailField(max_length=45, verbose_name="")
e_mail2 = models.EmailField(max_length=45, verbose_name="")
password = models.CharField(max_length=45, verbose_name="")
password2 = models.CharField(max_length=45, verbose_name="")
bir_date = models.DateField(auto_now=True, verbose_name="", blank=True, null=True),
class Meta:
managed = True
db_table = 'Users_data'
为什么不创建列 - bir_date
但是所有其余列都已创建?
答案 0 :(得分:3)
由于字段定义后面有逗号,因此bir_date
被视为tuple
。查看逗号如何更改变量的类型:
>>> s = "test"
>>> type(s)
<type 'str'>
>>> s = "test",
>>> type(s)
<type 'tuple'>
删除逗号,Django将“选择”该字段:
bir_date = models.DateField(auto_now=True, verbose_name="", blank=True, null=True)