Your STATICFILES_DIRS setting is not a tuple or list; " 。解决方案:找到settings.py文件,把STATICFILES_DIRS=(os.path.join(BASE_DIR,'static'))改为STATICFILES_DIRS=[(os.path.join(BASE_DIR,'static'))]。
使用Python发送邮件时,要明确要使用服务器的配置,目前来看,qq是不支持TLS传输协议的。
QUESTION:You are trying to add a non-nullable field 'xxx' to userprofile without a default
One option is to declare a default value for 'new_field':但是在第一次创建模型进行数据迁移是不会遇到此类问题
new_field = models.CharField(max_length=140, default='DEFAULT VALUE')
another option is to declare 'new_field' as a nullable field:
new_field = models.CharField(max_length=140, null=True)
If you decide to accept 'new_field' as a nullable field you may want to accept 'no input' as valid input for 'new_field'. Then you have to add the blank=True
statement as well:
new_field = models.CharField(max_length=140, blank=True, null=True)
Even with null=True
and/or blank=True
you can add a default value if necessary:
new_field = models.CharField(max_length=140, default='DEFAULT VALUE', blank=True, null=True)
另外两种不用添加默认值的方法:
做法1 暴力做法
使用python manage.py flush命令清空所有数据表中的数据,然后再删除migrations文件夹里所有py文件(除了init.py)。我们的模型一下回到原点,变成全新模型了,自然不会有问题啦。缺点是所有已有数据都丢失了。
做法2 推荐做法
先删除migrations文件夹里所有py文件(除了init.py),再运行运行python manage.py migrate。这时仅不符合新数据要求的company字段数据(比如Baidu)丢失,John和Max对象还在。如果数据表中已存在的数据还有价值,建议先对数据库被备份再执行migrate命令迁移。
以上内容为部分转载:
作者:妄心xyx
链接:https://www.jianshu.com/p/d52783987fec
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。