这是models.py
"cout"
这是我得到的错误
class Order(models.Model):
ORDER_STATUS = (
('created' , 'Created') ,
('paid','Paid'),
('shipped','Shipped'),
('refunded','Refunded'),
)
status = models.CharField(max_length=120 , choices=ORDER_STATUS , default='created')
cart = models.ForeignKey(Cart)
user = models.ForeignKey(UserCheckout , null=True)
address = models.ForeignKey(UserAddress , related_name='useraddress' , null=True)
Order_total_price = models.DecimalField(max_digits=10 , decimal_places=2)
order_id = models.CharField(max_length=20 , null=True , blank=True )
timestamp = models.DateTimeField(auto_now_add=True , auto_now=False)
delivered_by = models.DateTimeField(auto_now_add=True , auto_now=False)
将字段deliver_by添加到模型时出现此错误。如何解决此错误。谢谢
答案 0 :(得分:0)
您必须在模型中定义 str 或 unicode 方法,在python 3中定义str或在python 2中定义Unicode。我在方法中使用unicode(myfield)解决此问题我之前告诉过你。