如何在admin.StackedInline中显示更多内容
我有文章模型和评论模型。注释在 admin.py 中创建为 admin.StackedInline,它有几个字段,特别是 content 和 lastUpdate。对于lastUpdate,我指定如下:lastUpdate = models.DateTimeField('last update', auto_now=True)。可以理解的是,当我尝试添加新评论(或编辑旧评论)时,不会显示lastUpdate。但是,如果可能的话,我希望它以只读方式显示较旧的评论。有办法实现这一点吗?
多谢!
贾森
I have Article model and a Comment model. Comment is created in admin.py as admin.StackedInline, and it has several fields, notably content and lastUpdate. For lastUpdate, i have specified as follows: lastUpdate = models.DateTimeField('last update', auto_now=True). Understandably, lastUpdate is not displayed when i try to add new comment (or edit old ones). However, i would like it to display for older comments if possible, as a read only thing. Is there anyway of accomplishing that?
Thanks a lot!
Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想如果这个 http:// /docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields 没有做你想做的事情,看看这个:在 Django 表单中,如何将字段设置为只读(或禁用)以使其无法编辑?
I guess if this http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields doesn't do what you want it to do, have a look at this: In a Django form, how do I make a field readonly (or disabled) so that it cannot be edited?