A
A
Alex Xmel2022-04-16 18:17:35
Django
Alex Xmel, 2022-04-16 18:17:35

How to display the required fields in the admin filters in Django?

Comrades, tell me, otherwise I'm looking for it myself and I can't find it. There are two simple models. Coin model - all crypto coins and exchange model are listed here, some crypto exchanges are listed here. Relationship 1 to many. (I indicate on which exchange certain coins are circulating)
When I go to the exchange model in the admin panel, then the coins for the filter (list_filter) are displayed on the right in the column,
everything is fine, convenient, but the nuance is that there are a lot of coins, and in only 10 of them are connected to the table with exchanges. So I want this filter to display only the coins used, and not all of them. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-04-16
@Desead

well, so you make your filter from SimpleListFilter https://docs.djangoproject.com/en/4.0/ref/contrib/... in lookups you calculate "only used coins"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question