【发布时间】:2017-05-01 18:16:56
【问题描述】:
我正在尝试将 year_from 和 year_to 字段替换为模型中的 IntegerRangeField 字段,但在管理中添加新对象时出错。
问题是“错误绑定参数 4 - 可能是不受支持的类型。” 有人可以看一下并提供帮助吗?提前致谢!
models.py
from django.contrib.postgres.fields import IntegerRangeField
from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models
class Bancnote(models.Model):
DOLLAR = 'Dollar'
EURO = 'Euro'
TYPE_CHOICES = (
(DOLLAR , 'Dollar'),
(EURO, 'Euro')
)
type = models.CharField(max_length=20, choices=TYPE_CHOICES,
default=DOLLAR )
par = models.PositiveIntegerField()
year_from = models.PositiveIntegerField()
year_to = models.PositiveIntegerField()
year = IntegerRangeField()
size = models.CharField(max_length=7)
sign = models.CharField(max_length=20)
desc = models.TextField(max_length=200)
image = models.ImageField(upload_to='bons_images')
def __str__(self):
return str(self.par) + ' ' + self.type + ' ' + str(self.year_from) +
'-' + str(self.year_to)
【问题讨论】:
标签: python django python-3.x django-models