2016-08-12 3 views
-3

Models.pyここ

from django.db import models 


class Stock(models.Model): 
    ticker = models.CharField(max_length=10) 
    open = models.FloatField() 
    close = models.FloatField() 
    volume = models.IntegerField() 
    image = models.ImageField(upload_to=r'geeky.pythonanywhere.com/files', max_length=254,default="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRvj-aG0r4GBOQbne5fKQxoPdozZr81YZjrgM1etERa4RHWkvBOsw") 

    def __str__(self): 
     return self.ticker 

オタクは自分のユーザー名とpythonanywhere iはPythonスクリプトを実行するための私のサーバーのアカウントを持っている上のウェブサイトです!イメージやその他のファイルをwww.pythonanywhere.comやdjangoの他のサーバーのようなオンラインサーバーにアップロードするには? Pythonスクリプトを経由して

答えて

2

PythonAnywhere devのここでは、upload_to引数に完全な絶対パスを使用してみてください:「デフォルト」の引数にも

image = models.ImageField(
    upload_to='/home/geeky/mysite/files', 
    max_length=254, 
    default='/home/geeky/mysite/files/default.png' 
) 

(あなたは、それが今どこからそのデフォルトの画像をダウンロードする必要があるかもしれないとアップロードそれはPythonAnywhereに)...

関連する問題