在Django的Model中定义TextField字段导致无法在Mysql中生成表格

class Talk(models.Model):
    time = models.DateTimeField()
    content = models.TextField()

 

定义上面的Model后,使用manage.py syncdb一直无法看到表格生成的信息,当然mysql数据库中也的确没看到生成的表格。后来发现是TextField的问题,Mysql需要特殊的设置才能使用该字段,后来在Django的官方文档上看到了下面的一段话便豁然开朗:

 

TextField

class   TextField ( [ **options ] )

A large text field. The admin represents this as a  <textarea>   (a multi-line input).

MySQL users

If you are using this field with MySQLdb 1.2.1p2 and the  utf8_bin   collation (which is  not   the default), there are some issues to be aware of. Refer to the  MySQL database notes   for details.

具体可见:http://docs.djangoproject.com/en/1.1/ref/models/fields/#textfield

 

你可能感兴趣的:(mysql,数据库,django,database,Class,input)