开发过程中遇到的问题及解决方法

错误:

   "A model can't have more than one AutoField."
AssertionError: A model can't have more than one AutoField.
删除重复AUTO_ID后解决。

manage.py makemigrations BookTrade 
Migrations for ‘BookTrade’: 
BookTrade\migrations\0001_initial.py: 
- Create model BOOK 
- Create model TRADE 
- Create model USR 
- Add field BuyerId to trade 
- Add field Owner to book

manage.py migrate BookTrade 
Operations to perform: 
Apply all migrations: BookTrade 
Running migrations: 
Applying BookTrade.0001_initial… OK
错误:

1TypeError at /regist/

2render() takes at least 2 arguments (1 given)

解决方法:传一个空字典,或选择HttpResponse:
错误:

1.TemplateDoesNotExist at /regist/
2.{'key': 15340}


解决:

return render(request,'Regist.html',stk)
RuntimeError at /regist
You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:3000/regist/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
原因:url结尾未加/
Forbidden (403)
CSRF verification failed. Request aborted.
Form中添加 {% csrf_token %}
错误:TypeError at /regist/
'Telphone' is an invalid keyword argument for this function
错误:Variable    Value
args    ("'fdsf'", '416816', "'dfs'", "'[email protected]'", "'146161'")
db  <_mysql.connection open to 'localhost' at 4228fc0>
exc
query   "INSERT INTO `BookTrade_usr` (`Name`, `StuId`, `PassWord`, `Email`, `TelPhone`) 
VALUES ('fdsf', 416816, 'dfs', '[email protected]', '146161')"
res None
self    
value   OperationalError(1054, "Unknown column 'TelPhone' in 'field list'")

你可能感兴趣的:(django)