在Django中迁移模型时,如何解决SQLdecode错误? [英] How to solve SQLdecode error when you migrate models in django?
问题描述
我是django的新手,我创建了一个项目和应用程序,我想将我的项目连接到mongodb.输入python manage.py migrate
命令时,出现以下错误.
I am new to django, I have created a project and app and I would like to connect my project to the mongodb. when I enter python manage.py migrate
command , I am getting below mentioned error.
我删除了数据库,并清除了django_migration表中的所有迁移,并删除了创建的migrations文件夹中的迁移文件.仍然出现相同的错误.
I have dropped database and cleared all migrations in the django_migration table and deleted migration files in the created migrations folder. Still getting same error.
请帮助我.预先感谢
错误:
raise TypeError("documents must be a non-empty list")
TypeError: documents must be a non-empty list
上述异常是以下异常的直接原因:
The above exception was the direct cause of the following exception:
djongo.sql2mongo.SQLDecodeError: FAILED SQL: INSERT INTO "django_migrations" ("app", "name", "applied") VALUES (%(0)s, %(1)s, %(2)s)
Version: 1.2.31
Settings.py
Settings.py
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'DB_name',
'HOST':'localhost',
# 'PORT': 27017,
# 'USER':'',
# 'PASSWORD':''
},
models.py
models.py
from django.db import models
# Create your models here.
class dummy(models.Model):
name= models.CharField(max_length=100, blank=True, null= True)
推荐答案
我已经解决了这个问题,问题可能出在sqlparse的版本上-sqlparse 0.2.4很好用,但是sqlparse 0.3.0不好.
i have solved this problem, the problem may be the version of sqlparse -- sqlparse 0.2.4 works well, but sqlparse 0.3.0 not.
pip install sqlparse == 0.2.4 --user
pip install sqlparse==0.2.4 --user
对我有用,祝你好运!
这篇关于在Django中迁移模型时,如何解决SQLdecode错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!