"""
views.py
"""
def my_image_view(request):
image = models.Image.objects.first() # for example, you have a better way to get it from the DB :)
file_name = f"images/low/the_name_of_the_thumbnail_{image.id}_low.png"
context["file_name"] = file_name # or however else your context dict is called
return render("template", context=context)
最干净的方法是将文件名存储在view函数的变量中。大概是这样的:
相关问题 更多 >
编程相关推荐