I was wondering if its possible to make the below function generic so that it iterates through any given model and does not require all the fields to be stated in that model like the below function does.
def CustomerTable(ExampleModel):
CustomerInfo = ExampleModel.objects.all()
CustomerJson = []
for customers in CustomerInfo:
CustomerJson.append({
'ID': customers.ID,
'Title': customers.Title,
'Name': customers.Name,
'Description': customers.Description,
'Location': customers.Location,
'DateAdded': customers.DateAdded,
})
CustomerTable = {'Records' :CustomerJson}
Return HttpResponse (CustomerTable)
Thanks for all the help!