Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Admin Forms with additional fields in ManyToMany relations

I have 2 Entities with a ManyToMany Relation and some additional fields, here you can find an example diagram:

enter image description here

I created all models following the documentation and everything works, but I would also manage MTM relations using django admin without use another form to create a new "WheelsCar" row that links togheter a car and a wheel. Is it possible? How?

Admin use case:

  1. I click on add new Car
  2. I select one of the wheels, filling the additional fields (position, holes...)
  3. Iterate step 2
  4. Save a New Car
like image 207
Antonio Avatar asked Dec 29 '25 12:12

Antonio


1 Answers

I got it, I have to use Inline Fields!

Doc: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models

like image 169
Antonio Avatar answered Jan 01 '26 04:01

Antonio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!