如何在同一html页面上显示不同的Django视图,而不是显示不同的html页面

2024-09-24 10:28:55 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在同一个HTML(即home_2.HTML)上显示所有这些视图,以及如何编写URL

def Home(request):
    posts = Yogmodel.objects.filter
    return render(request, 'frontend/home_2.html', {'posts': posts })

def Viewfulltest(request):
    tests = Testimonial.objects.all()
    context = {'tests':tests}
    return render(request, 'frontend/testfullview.html', context)

def ViewAward2(request,id):
    #award = request.GET.get('award')
    awardphotos = AwardPhoto.objects.filter(award__id=id)
    awards = AwardTitle.objects.all()
    context = {'id':id,'awards': awards, 'awardphotos': awardphotos}
    return render(request, 'frontend/viewaward2.html', context)

Tags: idreturnobjectsrequestdefhtmlcontexttests