nrubin29 nrubin29 - 2 months ago 25
Python Question

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. 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. 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.

Thanks!

Answer

I fixed the issue by using an iframe to embed the page itself. I used the ?_popup=1 argument so that the navbar and other parts of the admin site wouldn't show up.