找不到Django ImageField图片

时间:2019-07-09 19:07:29

标签: django-views django-urls

以这种方式更改时不起作用

path('<str:gameslug>/player/<str:slug>',player_detail,name="player_detail"), //don't work 404 not found error

更改前(正在工作)

  path('player/<str:slug>',player_detail,name="player_detail"), // was working

models.py

image=models.ImageField(null=True,blank=True,upload_to='player')

错误:找不到页面(404)

1 个答案:

答案 0 :(得分:0)

我将upload_to='player更改为

  

现在更清楚

def create_path(instance, filename):
        import os.path
        return os.path.join(
             instance.game.slug,
             filename
        )

现在的网址; media / gameslug / filepath