我有一个模型,我使用基于类的CreateView
。
提交时我收到错误:
unorderable类型:int()> STR()
django-admin出现同样的错误。
我使用Django 1.7.4和Python 3.4
如何解决这个问题?
我的观点:
class CreateView(generic.CreateView):
model = HeatingPlant
template_name = 'heizwerk/form.html'
我的模特:
class HeatingPlant(models.Model):
name = models.CharField("Name", max_length="64")
street = models.CharField("Straße", max_length="32")
house_number = models.IntegerField("Hausnummer")
zip = models.IntegerField("Postleitzahl")
place = models.CharField("Ort", max_length="32")
phone_number = models.CharField("Telefonnummer", max_length="32", blank=True)
mail = models.CharField("E-Mail", max_length="64", blank=True)
#bank = models.ForeignKey(Bank, verbose_name="Bank", blank=True)
BIC = models.CharField("BIC", max_length=32, blank=True)
IBAN = models.CharField("IBAN", max_length=32 ,blank=True)
manager = models.CharField("Geschäftsführer", max_length="32")
Ust_ID = models.CharField("Ust ID", max_length=16)
company_register_number = models.CharField("Firmenbuchnummer", max_length="32")
last_reading = models.DateField("Datum letzte CSV-Auslese", blank=True, null=True)
standard_discount = models.IntegerField("Standardrabatt", default=0)
correction_factor = models.DecimalField("Korrekturfaktor", max_digits=8, decimal_places=2)
答案 0 :(得分:6)
参数max_length
的类型应为int
,而不是str
:
# name = models.CharField("Name", max_length="64")
# ^ ^
name = models.CharField("Name", max_length= 64)
其他字段相同