使用render时,Django将两次运行函数内容

时间:2019-06-25 04:46:57

标签: django python-3.x render

对不起,我的英语不好。我的问题是,在Google Chrome浏览器中刷新页面会使带有render的功能运行两次,但是在Firefox浏览器中运行一次。我不知道这是Google Chrome还是其他问题?(希望得到帮助,谢谢)

def add_teacher(request):
    Teacher.objects.create(username='zhangs',avatar='https://static-image.xfz.cn/11.jpg',jobtitle='a',profile='b')
    print('==')
    return render(request,'course/course_index.html')

Google和Firefox都运行相同的内容。

当Google Chrome浏览器刷新页面时,将创建两个教师的数据,但是在运行Firefox时仅创建一个数据。当Google运行时,Pycharm还将打印两个“ ==”内容。在Firefox上打印一张。

0 个答案:

没有答案