首页 > 解决方案 > 当 conetxt 包含路径时,Django 无法在模板中显示上下文

问题描述

通常我可以显示我的上下文中存在的任何变量,它可以工作。但是在这里,当我想在模板中显示一个包含路径的变量上下文时,它不起作用。我的路径在上下文变量中,因为我可以在控制台中打印他。我只遇到带有路径的上下文变量的这个问题

视图.py

def step0(request):
     context = {}
     if request.method == 'POST':
         context['GV.Levels_m0'] = GV.Levels_m[0]
         print(context['GV.Levels_m0'])
     else : 
         None
     return render(request,"template.html",context)

模板:

{% if export_process_done %}
      <div class="alert alert-success"><b>Done</b>.The files are exported to {{  GV.Levels_m0 }} </div>
{% endif %}

我的控制台:C:\Users\exex\Documents\name\WebApp\Application\media\projectname\process

渲染

标签: pythondjangovariablespath

解决方案


推荐阅读