Django问题记录

Django问题记录

error: Microsoft Visual C++ 14.0 is required问题最佳解决方法

https://lanzao.blog.csdn.net/article/details/87929616

官方工具:https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/

gitee | 备用下载

uwsgi安装失败

uwsgi不能安装在Windows,Windows对应的是wsgi

conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError

数据库连接错误,检查数据库配置文件。

模型到数据库迁移失败

  1. django_migrations中删除记录
	![在这里插入图片描述](https://img-blog.csdnimg.cn/20210108085943133.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxNzcwMzg1,size_16,color_FFFFFF,t_70)

  2. model.py中的options中managed设为True,同时把migrations目录下的迁移文件删除
  ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210108090002760.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxNzcwMzg1,size_16,color_FFFFFF,t_70)
  1. django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
    Django问题记录_第1张图片

django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet.

  [如何在Pycharm Pro中运行django测试,出现ImproperlyConfigured和AppRegistryNotReady错误](https://stackoom.com/question/3yC8h/如何在Pycharm-Pro中运行django测试-出现ImproperlyConfigured和AppRegistryNotReady错误)

first.models.Blog.DoesNotExist: Blog matching query does not exist.

  单元测试时,会生成测试数据库,执行完命令就会删除数据库。Blog表获取不到数据,提示该错误。

Object of type ‘Snippet’ is not JSON serializable

  1. 比如自定义的类或者date类型,都需要自定义jsonEncoder

  2. 或者用列表包含对象,使用如下方式。

     a = [obj]
     serialize = serializers.serialize('json', a)
    

你可能感兴趣的:(Django问题记录)