开发者

django: How to render CharField as a label in Model Admin page?

开发者 https://www.devze.com 2023-01-15 02:29 出处:网络
My Model has a CharField called \"comm开发者_开发知识库ents\". I want to display this as just a regular paragraph of text, instead of the default html textarea on the Model admin page. How would I go

My Model has a CharField called "comm开发者_开发知识库ents". I want to display this as just a regular paragraph of text, instead of the default html textarea on the Model admin page. How would I go about implementing this change?


I could be misunderstanding your question, but I think you want to take a look at Django's readonly_fields option.

readonly_fields = ('comments', )

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields


You'll want to create a custom widget and override the render() method.

0

精彩评论

暂无评论...
验证码 换一张
取 消