I currently have a django management command to import CSV files, which is based on this answer. The main business is done by the following line in a loop:
created = Customer.objects.get_or_create(account_no = int(row[0]), name = row[1])
However, because I have a number of different models to run this on, I wish to put the above code inside a function, and pass the attributes and row keys in from a dictionary; so I'd defnine something like:
csv_columns = { 0: 'account_no', 1: 'name' }
However I don't know how to run the get_or_create
function based on this. I'm sure this should be simple.