【原】Django问题总结

一:python manage.py makemigrations No changes detected

在修改了models.py后,有些用户会喜欢用python manage.py makemigrations生成对应的py代码。

但有时执行python manage.py makemigrations命令(也可能人比较皮,把migrations文件夹给删了),会提示"Nochangesdetected."可能有用的解决方式如下:

先python manage.py makemigrations --empty yourappname生成一个空的initial.py

再python manage.py makemigrations生成原先的model对应的migrationfile

二:django使用migrations迁移版本和数据库中报错解决方案

https://blog.csdn.net/a599174211/article/details/82795206

三:django-关于manage.py migrate无效的问题

https://blog.csdn.net/qq_25730711/article/details/60327344

四:解决在vscode中用python操作数据库模型时出现的Class "xxx" has no 'objects' member错误提示

https://blog.csdn.net/qq_36272282/article/details/89416663

五:关于线上部署admin后台样式没有生效的问题

1、在settings.py尾部:

STATIC_ROOT  = os.path.join(BASE_DIR, 'static')#指定样式收集目录
#或
STATIC_ROOT = '/www/mysite/mysite/static'  #指定样式收集目录
2、收集CSS样式,在终端输入:

python manage.py collectstatic
运行这个命令之后,就会自动把后台CSS样式收集到/static/目录下。刷新页面就能恢复样式!
原文地址:https://www.cnblogs.com/HYanqing/p/11615476.html