如何在Django模型中重命名函数,而不会在迁移过程中导致AttributeError

时间:2015-12-10 05:45:55

标签: python django

我有以下Django model.py

def cool_function(value):
    pass

class Method2(models.Model):
    inputfile_param     = models.FileField(validators=[cool_function])

我想要做的是将cool_function()重命名为某个名称even_cooler_function()

但是当我这样做时

python manage.py make migrations

我收到此错误:

AttributeError: 'module' object has no attribute 'cool_function'

我该如何处理这个问题?

1 个答案:

答案 0 :(得分:3)

打开导入旧功能的迁移文件 并调整参考。

从相关迁移文件中的cool_function()even_cooler_function()