小编Isa*_*h I的帖子

如何修复“django.db.utils.OperationalError:接近“无”:语法错误”db.sqlite3?

我正在尝试为我的 Django REST 框架创建一个用户模型,遗憾的是,我遇到了一些意想不到的困难:当我运行“python manage.py makemigrations”时,一切都按其应有的方式运行,但是,当我尝试运行迁移时,我遇到了这个错误“return Database.Cursor.execute(self, query) django.db.utils.OperationalError:near“None”:语法错误”。

我尝试更改 models.py 中的代码,但即使我将用户模型类设置为只有一个 id 字段,它仍然会产生相同的结果。我正在使用 django 版本 1.11.17 和 drf 版本 3.9.0

模型.py:

class User(models.Model):
    id = models.AutoField(primary_key=True)

    email = models.CharField(unique=True, null=False, max_length=200)
    phone = models.IntegerField(unique=True, null=False)
    first_name = models.CharField(null=False, max_length=200)
    last_name = models.CharField(null=False, max_length=200)
    is_active = models.BooleanField(_('active'), default=False)
    last_seen = models.DateTimeField(auto_now=True, null=True)
    updated_at = models.DateTimeField(auto_now=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True)

    avatar = models.CharField(null=True)
Run Code Online (Sandbox Code Playgroud)

迁移/0001_initial.py:

class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
    migrations.CreateModel(
        name='User',
        fields=[
            ('id', …
Run Code Online (Sandbox Code Playgroud)

python sqlite django manage.py

6
推荐指数
1
解决办法
4118
查看次数

标签 统计

django ×1

manage.py ×1

python ×1

sqlite ×1