Django中修改DATABASES后,执行python manage.py ****报错!UnicodeEncodeError: 'latin-1' codec can't encode character '\u2028' in position 9:ordinal not in range(256). 为了这个错误找了无数网页,花费数小时,结果在于配置的用户名密码是从微信电脑端上面复制过来的,里面有个分隔符(‘\u2028’),愚蠢的人类终于被自己蠢哭了!!! 解决方案:老老实实自己输入,…
出现 no changes detected python manage.py makemigrations No changes detected 为什么出现这种情况: 当执行这条命令,他会去找所有models,在数据库生成表 因为有时候app项目多的时候,他就不知道找哪个models了,不知道在哪个models生成数据库表 这里有models.py 需要要django setting配置文件 这里加上 app项目名字  例如 cmdb 那django就会去cmdb项目下 找models.py…
[问题原因]:django工程中存在多个应用,每个应用都指定了对应的数据库.执行python manage.py migrate命令时没有指定数据库,将只初始化默认的default数据库. [解决方案]:针对每个应用的数据库分别执行python manage.py migrate --database=app_db_name…
在执行python manage.py makemigrations时报错: TypeError: __init__() missing 1 required positional argument: 'on_delete' 解决方法: 在连接外键时加上: on_delete=models.CASCADE…
原因 执行命令 python manage.py makemigrations 报错 TypeError: __init__() missing 1 required positional argument: 'on_delete' 定义外键报错 解决办法 字段名称 = models.ForeignKey('表名', on_delete=models.CASCADE) on_delete=models.CASCADE 在 django2.0之前有默认值,之后版本就需要显式指定…
django项目中运行manage.py python manage.py runserver 出现如下错误提示: Traceback (most recent call last): File "manage.py", line 2, in <module> from django.core.management import execute_manager ImportError: cannot import name execute_manager 原因是django…
问题:django.db.utils.InternalError: (1049, "Unknown database 'main'") 在Django 配置的数据库上 执行  create database main  创建 main 数据库 问题:AttributeError: 'str' object has no attribute 'decode' 因为django对python2.x 和3.x支持不一样,在python3.x中需要 注释掉 以下代码(if的两句)…
Python3.6 用Django连接mysql一直报错django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None 百度好久没解决 ,不知道在哪看到了一个解决方法 贴出来. 错误 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required;…
报错: You are trying to add a non-nullable field 'BookName' to BookInfo without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing row…
使用python+selenium运行自动化脚本时,打印某一段文字出现UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)报错. 原因:编码未进行转换. 解决方式:print时,在后面加上encode("utf-8")即可. 例如: tx = driver.find_element_by_xpath(".//*[@id='1']/…