def parse_path(path): try: return path.split('/')[-2] # slug of the instance except IndexError: return None