I have to choose the ForeignKey field on the base of a condition, so can we create a method to return the field after fulfilling the condition and then use that method in the inline_reverse
Here what I tried:
class ReportAdmin(ReverseModelAdmin):
def get_report_model(self):
model = None
if ReportsModel.cdr_report is not None:
model = CurrencyDistributionModel
elif ReportsModel.cme_report is not None:
model = CurrencyManagementExpenditureModel
elif ReportsModel.cps_report is not None:
model = CurrencyProcessingStorageModel
elif ReportsModel.cma_report is not None:
model = CurrencyManagementAssetsModel
return model
search_fields = ['name']
inline_reverse = ['get_report_model']
I have to choose the
ForeignKey
field on the base of a condition, so can we create a method to return thefield
after fulfilling the condition and then use that method in theinline_reverse
Here what I tried: