Answer the question
In order to leave comments, you need to log in
How to create a field that appears depending on other fields?
I have some model and a model_type field described like this:
model_type = models.CharView(maxlength = 2, choice = [
('ST', 'Standard'),
('UN', 'Unlimited'),
('CU', 'Custom')
])
Answer the question
In order to leave comments, you need to log in
It can be done not through an abstract model, but through proxy models.
Each proxy model will have its own form with the required fields and a default value for model_type (in other words, one proxy model for each model_type)
But it's easier to add js to the admin page that hides certain fields when changing model_type
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question