django 內數據庫錯誤處理
錯誤處理:
django在遷移django.db.utils.InternalError: (1051, "Unknown table 'novel.user'")
-->django在創建model的時候,如果命名沖突或者把表刪了之后會報這樣的錯django.db.utils.InternalError: (1051, "Unknown table 'novel.user'")
解決:
先運行:
python manage.py migrate --fake
在運行:
python manage.py migrate
django.db.utils.InternalError: (1050, "Table 'tb_content' already exists")
django中同步數據庫時出現錯誤,錯誤代碼1050:
解決方法:python manage.py migrate content --fake
content是同步錯誤模型的應用名。
遷移文件是報錯 django.db.utils.InternalError: (1054, "Unknown column 'name' in 'django_content_type'")
解決:
1. 先刪除app(創建項目時創建的app)名字下的migrations下的除了init.py之外的文件
2. python manage.py makemigrations
python manage.py migrate
錯:django.db.migrations.exceptions.InconsistentMigrationHistory
--》 刪表
創建用戶:
createsuperuser
set time_zone = '+8:00';
admin 后台管理:
https://www.cnblogs.com/guokaifeng/p/11084997.html
blank = True 設置后可以不填
editable = False 不直接顯示
help_text = '提示信息'

# app01/admin.py:
class DepartmentAdmin(admin.ModelAdmin):
# 指定后台網頁要顯示的字段
list_display = ["id", "name", "create_date"]
class EmployeeAdmin(admin.ModelAdmin):
# 指定后台網頁要顯示的字段
list_display = ["id", "name", "age", "sex", "comment"]
# 注冊Model類
admin.site.register(Department, DepartmentAdmin)
條數限制:
https://blog.csdn.net/weixin_41790086/article/details/80726585
xadmin 配置:
https://www.cnblogs.com/lyq-biu/p/9513888.html