Python错误汇总(Django,FastApi)

2 篇文章 0 订阅
1 篇文章 0 订阅

1、 error in anyjson setup command: use_2to3 is invalid.

			pip install setuptools==57.5.0

2、 ImportError: cannot import name ‘render_to_response’

			修改报错文件的引入:*\site-packages\djcelery\admin.py
 			from django.shortcuts import render_to_response
			替换为
			from django.shortcuts import render

3、 ModuleNotFoundError: No module named ‘django.core.management.validation’

			pip install setuptools==57.5.0

4、 关于OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: ‘<frozen importlib._bootstrap>‘解决方法

			查看settings内的apps里是否有不存在或者已删除或存在报错的内容

5、django.core.exceptions.ImproperlyConfigured: The included URLconf ‘<module ‘apps.expense_cdn’ from ‘E:\expense_system\apps\expense_cdn\init.py’>’ does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

			views.py文件中没有patterns进行匹配,导致找不到路径	
			查看项目下的urls.py文件中路径指向,include()路径是指向了视图函数文件,导致无法匹配
			有些错误是因为创建的应用中缺少urlpatterns也会报同样的错误。将之前指向views文件的指向urls即解决了问题

6、python manage.py makemigrations,执行不生成迁移文件

		1、查看settings  INSTALLED_APPS是否添加,或者添加至   ***.apps.***Config
		2、如果是多个app,并且单独app内新建了models文件夹,在models文件夹内__init__内
			 from .你的models文件名称 import *
		3、基本即可解决
			 

7、django在上传文件过程中的报错

	报错如下:
		[uwsgi-body-read] Timeout reading 45256 bytes. Content-Length: 2043522 consul
		OSError: timeout during read(65536) on wsgi.input
		django.http.request.UnreadablePostError: timeout during read(65536) on wsgi.input
	解决方式:
		1、首先查看nginx的缓冲区的设置
		2、查看uwsgi的最大允许上传文件的大小设置
		3、如果都设置正确,name优先选择重启nginx,一般可以解决,不行在重启项目
		以上是我遇到时候的解决办法

8、model创建或者修改后的错误

	报错如下:
		Please select a fix:
	 		1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
			2) Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
			3) Quit, and let me add a default in models.py
		
	解决方式:
		可以删除本地management内的init文件,并删除数据库django_migrations内对应的记录

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

粘人的小妖精呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值