原因为视图里面返回的参数名使用错误导致,视图返回参数的格式是字典,在前台使用的时候需要使用其key加上其对象(即可调用values的对象的值)

def detail(request,hero_id):
    hero=models.HeroInfo.objects.get(id=hero_id)
    return render_to_response('detail.html',{'detail_obj':hero})

这个方法返回的参数{'detail_obj':hero},需要使用detail_obj

前台调用:

 <h4>{{ detail_obj.heroname }}</h4>

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案