首页 > 解决方案 > django.db.utils.ProgrammingError 尽管删除了有问题的代码

问题描述

即使我从我的 models.py 文件中删除了有问题的代码,我仍然会收到以下错误。当我尝试将主键设置为 UUID 字段时,首先出现了问题。从那时起,我不断收到如下所示的错误。删除数据库并重新运行迁移仍然会引发错误。

这是我的models.py文件

class VolunteerInstance(models.Model):
student_id = models.CharField(
    blank = True, 
    editable = True, 
    default = 'No Student ID Provided',
    max_length = 255
)
grad_year = models.CharField(
    blank = True, 
    max_length = 255,  
    default = 'No Graduation Year Provided', 
    editable = True
)
organization = models.CharField(
    blank = False,
    max_length = 255
)
description = models.TextField(
    blank = False, 
)
supervisor_Name = models.CharField(
    blank = False, 
    max_length = 255
)
supervisor_Phone_Number = models.CharField(
    blank = True, 
    null = True, 
    max_length = 10
)
volunteering_Date = models.DateField()
volunteering_Duration = models.FloatField()
scanned_Form = models.FileField(
    null = True,
    blank = True, 
    upload_to = 'scanned_files' 
)
approved = models.BooleanField(
    default = False, 
    blank = True, 
)

这是我不断收到的错误。

File "C:\Program Files\Python38\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.CannotCoerce: cannot cast type bigint to uuid
LINE 1: ...unteerinstance" ALTER COLUMN "id" TYPE uuid USING "id"::uuid

标签: databasedjango-models

解决方案


推荐阅读