def insert_media_types(): # delete records (if any) MediaTypeModel.objects().delete() # loop through records for media_type in media_types: # create record media_type_model = MediaTypeModel(**media_type) # insert record media_type_model.save()
def insert_events(): # delete records (if any) EventModel.objects().delete() # loop through records for event in events: # find media_type record event['media_type'] = MediaTypeModel.objects( media_type=event['media_type']).first() # find block record event['block'] = BlockModel.objects( block_number=event['block']).first()['block_id'] # create record event_model = EventModel(**event) # insert record event_model.save()