python - 附加查询字符串以查看渲染函数 Django
问题描述
我querystring
认为:
def my_view(request):
query_string = request.GET
然后我在这个视图中做了一些工作人员。最后,我想querystring
在页面完全呈现时附加到视图的 URL:
return render(request, 'my_template.html', context=context) # Want to add querystring here!
简而言之,我想附加querystring
到视图渲染功能或类似的东西。我怎样才能做到这一点?
渲染过程:
我想我必须宣布我的目的。我将解释所有渲染过程并定义我的意思。看:
用户点击进入该视图的链接(发送请求)。假设这是我们的链接:
site.com/my/page/?q1=value_1&q2=value_2
查看函数调用:
# urls.py path('my/page/', my_view) # views.py def my_view(request): query_string = request.GET
request
使用,template
和渲染模板context
:return render(request, 'my_template.html', context=context)
完成 html 和所有静态文件后,我们就有了 html 页面,其中包含
URL
和html
.
我想将我的主节点添加querystring
到进程 4 的 URL。我该怎么做?
解决方案
推荐阅读
- c++ - “整数常量太大以至于它是无符号的”编译器警告理由
- vert.x - Vert.x Web Api 服务/合约中的前缀路径
- amazon-web-services - AWS ECS:没有容器实例满足其所有要求
- jsdoc - 在不是 Github Pages 的网站上托管更好的文档文档?
- css - CSS - 是否可以在不使用负值的情况下将大于其父级的绝对元素居中(水平)?
- javascript - 需要时如何将整个对象转换为数组?
- java - Maven - 尽管存在,但在中央存储库中找不到杰克逊工件?
- python - 如何使用plotly(Python)将鼠标悬停在具有相同x轴的多个图表上?
- python - 在 matplotlib.pcolor() 中使用 x、y 数组作为像素位置和 z 作为颜色值时的参数数量错误
- python - 如果字段值在外部列表中,Django 注释布尔值