def writing(self, base_data): weather, created = Weather.get_or_create(date=base_data[0].date(), defaults={ 'temp_d': base_data[1], 'cloud_d': base_data[2], 'wind_d': base_data[3], 'pres_d': base_data[4], 'temp_n': base_data[5], 'cloud_n': base_data[6], 'wind_n': base_data[7], 'pres_n': base_data[8] }) if not created: weather = Weather.update( temp_d=base_data[1], cloud_d=base_data[2], wind_d=base_data[3], pres_d=base_data[4], temp_n=base_data[5], cloud_n=base_data[6], wind_n=base_data[7], pres_n=base_data[8]).where(Weather.id == weather.id) weather.execute()