Answer the question
In order to leave comments, you need to log in
How to specify dependency between fields?
For example, in the model there are 2 fields, one of them is BooleanField, how to make it so that if it is true, then the 2nd field is displayed in the admin panel, and if the fall 2 is not displayed
Answer the question
In order to leave comments, you need to log in
@admin.register(SomeModel)
SomeModelAdmin(admin.ModelAdmin):
def get_fields(self, request, obj=None):
fileds = super().get_fields(request, obj)
if obj and not obj.first_field:
fields.remove('second_field_name')
return fields
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question