I have a model that is managed by the admin of django, in admin.py and create a method that adds some model fields to the property readonly_fields when the object has already been created, so when I entered to modify the object I the fields appear like this:
def get_readonly_fields(self, request, obj=None):
if obj: # editing an existing object
return self.readonly_fields + ('tipo_documento', 'num_documento', 'nombres', 'apellidos')
return self.readonly_fields
Now I need to make a conditional to know if there is a value in one of the fields to add it to the property readonly_fields, and try the following condition but it did not work
if obj.nombre_campo:
return self.readonly_fields + ('otro_campo')
basically I need to know how to access the values of an input to be able to make the condition
the fields I want to add to readonly_fields as long as they have values are the following: