Django 中 render() 函数的 "context" 参数有什么作用?

What does the "context" argument to the render() function in Django do?

我正在学习关于 Django 的基本博客教程,在创建应用程序后我必须将它添加到视图中,我不明白的是 什么 渲染函数' 参数 CONTEXT 是为了我们为什么要使用字典。

我已经看过官方文档了,但是看不懂

这是我正在做的。

    render(request,'users/register.html', { 'form': form})

您在 context 参数中提供的内容在模板中可用。因此,在您的示例中,您可以在 html 模板中访问表单。

它提供要在模板中显示的变量。

例如,如果您的模板有这样的 html:

<p>Hello {% first_name %}.</p>

如果您在上下文中传递 first_name 变量:

render(request,'users/register.html', {'form': form, 'first_name': 'John'})

模板将显示 Hello John.