在开始之前,我已经查看了类似的错误,但似乎无法找到问题所在。
背景:我正在 Django 中使用 model.py 创建一个注册表单。我在我的开发环境中运行了表单。一旦我将数据输入到表单中,它应该将它保存在 sqlite3 db 中。但是目前,当我完成填写表格时,我看到两个问题。这些如下
问题: 1)尽管在“电子邮件”字段中有一个电子邮件地址,但它会出现“此字段不能为空”。所以我然后在我的 models.py 文件中添加 'null=true' 用于电子邮件。完成此操作并重试后,我得到:2) 另一个错误,提示“此字段不能为空”。然后我在我的 models.py 文件中为电子邮件添加 'blank=true'。这使我能够完成表格并注册数据。但是现在,我遇到了问题 3 3)当我进入数据库并单击查看谁注册时,它会在电子邮件应在的位置显示“无”。当我点击“无”时,我看到以下错误(我的代码如下):
TypeError at .............
coercing to Unicode: need string or buffer, NoneType found
Request Method: GET
Request URL: ......
Django Version: 1.8.2
Exception Type: TypeError
Exception Value:
coercing to Unicode: need string or buffer, NoneType found
Exception Location: /Library/Python/2.7/site-packages/Django-1.8.2-py2.7.egg/django/utils/encoding.py in force_text, line 92
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/Users/Desktop/Website/booksrc',
'/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg',
'/Library/Python/2.7/site-packages/Django-1.8.2-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', …Run Code Online (Sandbox Code Playgroud)