def get_build_path(self, obj):
url = self.get_url(obj)
if url.startswith('http'):
# Multisite has absolute urls
url_parsed = urlparse(url)
path = url_parsed.path
hostname = url_parsed.hostname
if getattr(settings, 'BAKERY_MULTISITE', False):
build_path = os.path.join(
settings.BUILD_DIR, hostname, path[1:])
else:
build_path = os.path.join(settings.BUILD_DIR, path[1:])
else:
# Single site has relative urls
build_path = os.path.join(settings.BUILD_DIR, url[1:])
# Make sure the (deeply) directories are created
os.path.exists(build_path) or os.makedirs(build_path)
# Always append index.html at the end of the path
return os.path.join(build_path, 'index.html')
评论列表
文章目录