django - How does Django knows which template to render when?
问题描述
I am on 4th chapter the book Django 3 by example and I noticed one thing that we are only creating views from Django's authentication framework but we are not telling those views which template to render when. For example, how does my application would know that it needs to only render the logged_out.html template when we try to access the logout view? If I try to change the name of the file from logged_out.html to loggedout.html then it takes me to the Django's admin logout page.
Why?
解决方案
在 django 视图中,对于我们在最后编写的每个视图
return render(request, 'your template location')
这就是 django 知道为哪个视图渲染哪个模板的方式。
推荐阅读
- c++ - 标称数据上的 C++ std::set_operations(set_difference、set_intersection 等)
- android - 与 Activity 分开打开的片段不显示操作栏
- javascript - 在 jest 框架中无法处理具有三元运算符检查的 const 值
- azure - 动态使用数据流处理多个表
- swift - Core Data 获取具有两个匹配字段的记录
- node.js - 如何从请求中返回值?
- c# - 使用最新数据 C# 刷新 Access 数据库
- machine-learning - 使用梯度下降的神经网络
- python-3.x - 一张表有两种方法的关联表
- kubernetes - 我看到使用“az 磁盘列表”的空磁盘列表。在 AKS 中创建并且工作正常