2
我有這個媒體根:Django上傳文件url問題
MEDIA_ROOT = '/var/www/hosted/myapp/static/'和這個媒體網址
MEDIA_URL = '/static/res/'我試圖上傳一個文件使用callable:
def get_uploadto(instance, filename): ''' Dummy callable to silence the upload_to field of FileFields ''' return os.path.join('uploads', filename),它將圖片上傳到/ var/www /託管在磁盤上/ myapp/static/uploads /就像計劃的那樣,但是在管理員中,它創建了一個鏈接,指向靜態/ res /上傳,這不存在。有誰知道爲什麼?當然,我可以簡單地將上傳目錄移動到靜態數據庫中,但我正在尋找更優雅的解決方案。
是否希望遠程用戶可以訪問這些文件?然後,您需要將網址映射到路徑。 – agf