def import_dates(modeladmin, request, queryset): with open('D:/Users/mcpherro/PycharmProjects/Sites/dates.csv', 'rb') as f: reader = csv.reader(f) for row in reader: d = Date(id=row[0], site_id=row[1], layer=row[2], industry=row[3], industry_2=row[4], industry_3=row[5], cat_no=row[6], sample=row[10], technique=row[11], hominid_remains=row[15], bibliography=row[16], period=row[17], notes=row[18]) if row[7] != 'NA': d.date = row[7] if row[8] != 'NA': d.sd_plus = row[8] if row[9] != 'NA': d.sd_minus = row[9] if row[19] != 'NA': d.intcal09_max = row[19] if row[20] != 'NA': d.intcal09_min = row[20] if row[12] != 'NA': d.corrected_date_BP = row[12] if row[13] != 'NA': d.plus = row[13] if row[14] != 'NA': d.minus = row[14] d.save() return None # Return None to display the change list page again.