2017-05-01 45 views
0

我試圖用year字段替換year_from和year_to字段,該字段在我的模型中是IntegerRangeField,但在admin中添加新對象時出錯。Django 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) 

回答

0

它看起來像IntegerRangeField是PostgreSQL的特定形式字段(IntegerRangeField)。讓我們知道您是否使用PostgreSQL。

+0

我的不好,是使用sqlite3作爲默認,現在在postgresql上正常工作。非常感謝! – Michael

相關問題