[Answered ]-Inline edit all ForeignKey related to a model[django admin]

2πŸ‘

βœ…

It’s wrong by design. 2 solutions to fix that:

  1. Use normal foreign key inside MenuButton and limit count of buttons in other ways (better solution)
  2. User OneToOneFields instead of foreign keys (not that good as first, explained later)

When 1st solution used, you can limit and assure that there will be always 4 and only 4 buttons inside your admin (or view, if you will allow to edit it outside admin). There are max_num and min_num attributes that you can provide into inline admin. You can also override has_add_permission and has_delete_permission to remove at all add and remove features from admin, by returning false in all cases.

when using 2nd solution, you can also do that, but queries for getting all buttons will be more complex and less optimal. So you should stick to 1st design.

πŸ‘€GwynBleidD

Leave a comment