2
私は、DokuSuite(1.10.6)をHerokuに、ランタイムPython 3.6.1に展開しようとしています。アプリは、(テーブルが作成されていないという事実を除いて)正常に動作しますが、私は次のエラーを取得するmakemigrations実行しようとしたとき:herokuでDjangoの作成が失敗する
Running python manage.py makemigrations on prochu1991... up, run.2221 (Free)
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/lib/utils.py",
line 667, in open_for_read
return open_for_read_by_name(name,mode)
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/lib/utils.py",
line 611, in open_for_read_by_name
return open(name,mode)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Windows\\Fonts\\Ver
dana.ttf'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/lib/utils.py",
line 670, in open_for_read
return getBytesIO(datareader(name) if name[:5].lower()=='data:' else urlopen
(name).read())
File "/app/.heroku/python/lib/python3.6/urllib/request.py", line 223, in urlop
en
return opener.open(url, data, timeout)
File "/app/.heroku/python/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/app/.heroku/python/lib/python3.6/urllib/request.py", line 549, in _open
'unknown_open', req)
File "/app/.heroku/python/lib/python3.6/urllib/request.py", line 504, in _call
_chain
result = func(*args)
File "/app/.heroku/python/lib/python3.6/urllib/request.py", line 1388, in unkn
own_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: c>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 137, in TTFOpenFile
f = open_for_read(fn,'rb')
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/lib/utils.py",
line 672, in open_for_read
raise IOError('Cannot open resource "%s"' % name)
OSError: Cannot open resource "C:\Windows\Fonts\Verdana.ttf"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/_
_init__.py", line 367, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/_
_init__.py", line 316, in execute
settings.INSTALLED_APPS
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py"
, line 53, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py"
, line 41, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py"
, line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in i
mport_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/app/Gry/settings.py", line 19, in <module>
pdfmetrics.registerFont(TTFont('Verdana', 'C:\Windows\Fonts\Verdana.ttf', 'U
TF-8'))
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 1147, in __init__
self.face = TTFontFace(filename, validate=validate, subfontIndex=subfontInde
x)
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 1042, in __init__
TTFontFile.__init__(self, filename, validate=validate, subfontIndex=subfontI
ndex)
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 412, in __init__
TTFontParser.__init__(self, file, validate=validate,subfontIndex=subfontInde
x)
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 161, in __init__
self.readFile(file)
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 239, in readFile
self.filename, f = TTFOpenFile(f)
File "/app/.heroku/python/lib/python3.6/site-packages/reportlab/pdfbase/ttfont
s.py", line 147, in TTFOpenFile
raise TTFError('Can\'t open file "%s"' % fn)
reportlab.pdfbase.ttfonts.TTFError: Can't open file "C:\Windows\Fonts\Verdana.ttf"
settings.py
import os
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.fonts import addMapping
#PDF Settings
pdfmetrics.registerFont(TTFont('Verdana', 'C:\Windows\Fonts\Verdana.ttf', 'UTF-8'))
addMapping('Verdana',0,0,'Verdana')
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '+hi1^3uy-5p=h!pq9-(og2$hu$ojw(&97d%71%cnkjeky*4&)#'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'Gry.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'Gry.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
LOGIN_URL = 'login'
LOGOUT_URL = 'logout'
LOGIN_REDIRECT_URL = 'home'
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
を私はsqliteのを使用しています。
しかし、どのように相対パスを使用する必要があるのですか?そして、私はどのように私のttfファイルをハードコードできないのですか? – Prochu1991
スタティックパスの場合とまったく同じ方法です。そして、私はあなたのプロジェクトの中にファイルがある必要があると言います - あなたはHerokuがあなた自身のWindowsディレクトリからどのように読むことができると思いますか? –