2014-10-20 45 views
0

我更新我的应用程序Django的1.7,并试图python manage.py makemigrations,出现以下错误的结果:Django的与RegexValidator makemigrations引发TypeError

TypeError: unbound method deconstruct() must be called with RegexValidator instance as first argument (got nothing instead)

为MyModel:

from django.core.validators import RegexValidator 
name = models.CharField(max_length=50, validators=[RegexValidator]) 

在现实它更复杂,但我认为这会导致错误。我正在使用Python 2.7。

我读过关于migrations的Django文档,包括Adding a deconstruct() methodRegexValidator,但我不明白如何摆脱错误。

回答

1

你要通过正则表达式验证器的一个实例,而不是类型:

name = models.CharField(max_length=50, validators=[RegexValidator(your_regex)])