5
這是我使用的模型:如何通過DateTimeField訂購django-mptt樹?
class Comment(MPTTModel):
comment = models.CharField(max_length=1023)
resource = models.ForeignKey('Resource')
created_at = models.DateTimeField(auto_now_add=True)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
author = models.ForeignKey(User)
class MPTTMeta:
order_insertion_by = ['created_at']
然而,當我嘗試從管理網站,我得到添加註釋:
ValueError at /admin/app/comment/add/
Cannot use None as a query value
我做得不對我的模型?我覺得在django-mptt設置爲db級別之前,它試圖獲取DateTimeField,而它仍然是「None」。