Django admin form to populate in different models

I am working on a project in which I want to populate data on two different Django models using the same admin form. Some fields of those models are common but not all. Also, there is no relationship between any two fields of those models so can’t able to use Django admin inline functionality. If you have any ideas or any approach, please let me know it would be very helpful for me.

First reaction is that this fits into the category of what’s described in the Admin site docs:

The admin has many hooks for customization, but beware of trying to use those hooks exclusively. If you need to provide a more process-centric interface that abstracts away the implementation details of database tables and fields, then it’s probably time to write your own views.

You might be able to do this using a custom Admin form with a custom save_model method.
Pick one of the models as the “base” model for the form, and create individual fields for the second model. Build your second model instance from those form fields and save it in your save_model method.

1 Like