我在网页上的django应用程序中有一个视图函数,用户自己编写代码(使用他们已知的框架)。上传代码后,它们将被重定向到他们为其编写代码的网页。我希望有一种方法可以逐行显示在视图函数上运行的python代码,因为它可以清楚地向用户显示其代码的工作方式。有没有办法在网站上调试代码?
答案 0 :(得分:0)
您可以使用print()函数。
如果在视图中使用print()函数,则在执行该视图函数时,它将在命令行或终端上打印。
在views.py中
def indexView(request):
productCat = Product_Cat.objects.order_by('name')
upcoming = Upcoming_Product.objects.all()
print(upcoming)
return render(request,'website/index.html',{'productCat':productCat})
在终端:
<QuerySet []>
答案 1 :(得分:0)