简体   繁体   English

Django嵌入管理表单

[英]Django Embed Admin Form

I am trying to embed the exact form that appears in the Django admin when I edit a model in a different page on my website. 当我在网站的其他页面上编辑模型时,我试图嵌入显示在Django管理员中的确切形式。 My plan is to have an Edit button that, when clicked, displays a modal with the edit page inside of it. 我的计划是要有一个“编辑”按钮,当单击该按钮时,将显示一个带有其内的编辑页面的模式。

The issue with using a ModelForm is that this particular model has two generic foreign keys. 使用ModelForm的问题在于该特定模型具有两个通用外键。 The admin handles this perfectly, providing the ability to add, edit, or remove these objects. 管理员可以完美地处理此问题,从而可以添加,编辑或删除这些对象。 If I could embed the admin page (with its HTML or perhaps my own), that would be all I need. 如果我可以嵌入管理页面(包括HTML或我自己的页面),那将是我所需要的。

Thanks! 谢谢!

I fixed the issue by using an iframe to embed the page itself. 我通过使用iframe嵌入页面本身解决了该问题。 I used the ?_popup=1 argument so that the navbar and other parts of the admin site wouldn't show up. 我使用了?_popup=1参数,以便导航栏和管理站点的其他部分不会显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM