def load_demo_data(self): try: timeseries = TimeSeries.objects.get(slug=self.demo_timeseries['slug']) timeseries.delete() except TimeSeries.DoesNotExist: pass timeseries = TimeSeries(**self.demo_timeseries) timeseries.save() data_path = os.path.join(os.path.dirname(openorg_timeseries.demo.__file__), 'data', 'example_data.csv') readings = [] with open(data_path, 'r') as f: reader = csv.reader(f) for row in reader: readings.append([dateutil.parser.parse(row[0]), float(row[1])]) timeseries.append(readings)