Django makemigrations在heroku中失败了

时间:2017-06-17 17:34:10

标签: python django heroku migrate makemigrations

我正在尝试将一个Django(1.10.6)应用程序部署到Heroku,运行时Python 3.6.1。该应用程序成功运行(除了未创建表的事实),但在尝试运行makemigrations时,我收到以下错误:

private void savepicture()
{  
    if(pictureBox1.Image != null)
    {
        MemoryStream ms = new MemoryStream();
        pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
        byte[] a = ms.GetBuffer();
        ms.Close();
        cm.Parameters.Clear();
        cm.Parameters.AddWithValue("@picture", a);
        cm.CommandText = "insert into Bild (FileName,Datei) values ('" + label1.Text.ToString() + "',@picture )";

        sc.Open();
        cm.ExecuteNonQuery(); // i get here the error message
        sc.Close();
        label1.Text = "";
        pictureBox1.Image = null;
        MessageBox.Show("Bild wurde gespeichert !");
    }
}

settings.py

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"

我正在使用sqlite。

1 个答案:

答案 0 :(得分:0)

好吧,您已将ttf文件的路径硬编码到本地Windows计算机上的某个位置。显然,这不会对Heroku起作用。您需要确保该文件位于报表中并使用相对路径。

另外,你不能在Heroku上使用sqlite。幸运的是,您的DATABASES设置将被覆盖,因为您使用的是dj_database_url。