def get_category_or_404(path):
 path_bits = [p for p in path.split('/') if p]
 return get_object_or_404(Category, slug=path_bits[(-1)])

def get_category_or_404 ( path ) : path_bits = [ p for p in path . split ( '/' ) if p ] return get_object_or_404 ( Category , slug = path_bits [ ( - 1 ) ] )
retrieve a category instance by a path .