[英]Heroku can't connect fonts
我已经下载了使用 xhtml2pdf 转换为 pdf 的 html 模板字体。 我没有设法用谷歌搜索对我有用的答案。 我认为该路径已更改,但在 heroku bash 路径未更改。 这是我的代码:
字体在发票/静态/发票/字体中
设置.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'main/static'),
#os.path.join(BASE_DIR, 'invoices/static'),
#BASE_DIR / "static",
]
STATIC_ROOT os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage. CompressedManifestStaticFilesStorage'
html字体连接
<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Инвойс #{{invoice_id}}</title>
<style>
@font-face {
font-family: 'Roboto-Medium';
src: url(../invoices/static/invoices/fonts/Roboto-Medium.ttf);
}
</style>
所以它发现当部署在 heroku 上时,你必须使用 ./path_to_fonts 而不是 ../path_to_fonts。 希望这会帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.