单个ModelAdmin中的多个模型 [英] Multiple models in single ModelAdmin

查看:43
本文介绍了单个ModelAdmin中的多个模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将多个模型注册到单个ModelAdmin.我希望django在单个页面中显示多个模型.像内联一样,但没有任何外键.

Is there any way to register multiple models to single ModelAdmin. I want django to show multiple models in single page. Like inlines but without any foreign key.

对于一项工作,我有一个用户模型和另一个设置模型.它获取推特用户及其推文.我通过使用TabularInline将用户和推文聚集在一起.但是,还有另一种称为设置"的模型,用户可以确定要显示的推文数量,每位用户的推文数量等.我想将所有这些都显示在一个ModelAdmin/一页中.

I have one user model and another settings model for a single work. It fetches twitter users and their tweets. I get users and tweets together by using TabularInline. However there is another model called settings where a user can determine number of tweets to show, number of tweets per user etc. I want to show all of them in one ModelAdmin/ one page.

推荐答案

如果一个模型与另一个模型不相关,则不能在一个页面中编辑两个模型.它超出了Django Admin的范围.

You can't edit two models in one page if one is not related to the other. It is out of the scope of Django Admin.

Django Admin仅用于简单的管理界面.如果需要高级行为,则必须编写自己的视图.您可以将视图添加到Django Admin .

Django Admin is only intended for simple admin interface. If you need advanced behaviors you will have to write your own views. You can add views to Django Admin.

这篇关于单个ModelAdmin中的多个模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆