K
K
kukarekuu2019-11-12 13:20:37
Django
kukarekuu, 2019-11-12 13:20:37

How to add lookup to admin panel?

I have a customized admin panel where I can edit Django objects (perform CRUD operations). I edit one of the fields in the admin panel (for example, the field is called " field1 " in the " table1 " model) manually, enter the desired value, click save - everything is ok, the object changes, the record in the database is saved (on the first screenshot)
5dca85695434b647323735.png
But this is not very convenient . Is there any way to make the entry in field1 selectable from a drop down list? Which, in turn, would be formed from the records of the field2 column of another table table2 ?
Approximately I tried to depict what I want to get in the second screenshot)
5dca86612a2cc003270303.png
That is, tables table1 andtable2 are linked by some foreign key, and this same foreign key must be pulled from another table to the drop-down list
. I did not find how this can be implemented using standard admin methods. Is there any way to quickly add such functionality in the admin panel?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question