开发者

Create/update a sub-object in the Django admin edit dialog

开发者 https://www.devze.com 2023-01-22 19:15 出处:网络
I\'d like to create/update a \"sub-object\" within an admin edit dialog. I have a \"CmsObject\" model, which contains several \"CmsPageItem\" objects (currently there will be just one fixed CmsPageIt

I'd like to create/update a "sub-object" within an admin edit dialog.

I have a "CmsObject" model, which contains several "CmsPageItem" objects (currently there will be just one fixed CmsPageItem, but that will change in the future). Rather then letting a StackedInline widget control the layout, I would like to displa开发者_运维问答y one additional textarea field somewhere in the change_form.html page.

What would the recommended approach to extend the ModelAdmin dialog be? I expect I need to push a formfield somewhere, or introduce new values in the template context?


Have you looked at TabularInlines? There is an example here: http://docs.djangoproject.com/en/dev/intro/tutorial02/


I've eventually settled to implement the whole view myself. For most simple objects, implementing the inlines (either with a custom template, or without) is good enough. In this situation I require more control, so I've overwritten the entire add_view and change_view completely.

FeinCMS also does this for it's editor window.

0

精彩评论

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