I want to make some advanced customization of Django admin form.
While editing an object, I want to show, dynamically, different fields depending of 1 obj field (they are not visible while adding the obj.). There can be a situation, to validate that extra fields. For example, when object has a 'temporary' type, I must show 2 fields with dates, and validate them. If object is 'renewable' I need to show 2 different fields with different validation. I've searched a lot of pages, but nowhere found 1 strict method.
What is the best approach to do that?
- Make separate
Form
for each object type and set form attrib ofModelAdmin
? If yes, in whichModelAdmin
method do that (change_view()
?)? - Dynamically update fields in
get_form()
method?
What is the best approach to do that?