我不熟悉Pycharm(v2019.2)和Django(2.2.4)。我试图理解不同文件中的代码片段,并试图将数据打印到Pycharm底部的窗口,即Run,管理.py,终端,Python控制台。在
我试过各种解决办法。我已经根据Django教程将日志添加到settings.py
文件中,并导入logging
。什么也没出来。我也尝试过在Pycharm中编辑Run>;配置,但是没有用。在
#views.py
from django.shortcuts import render, redirect
from .models import Customer
def index(request):
if request.user.is_authenticated:
groups = Customer.objections.select_related('group').values('name', 'address', 'group__name', 'group__limit')
print(groups)
for item in groups:
print(item)
context = {'group_list': {'data': list(groups)}}
return render(request, 'index.html', context, request.user)
else:
return redirect('/accounts/login')
我的页面加载良好,但我没有看到任何输出到我的控制台。在
试试这个:
文档:https://docs.python.org/3/howto/logging.html
相关问题 更多 >
编程相关推荐