在django中追加一个查询字符串到URL [英] Append a querystring to URL in django

查看:196
本文介绍了在django中追加一个查询字符串到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数调用另一个函数并将查询字符串传递到URL的末尾。

I have a function that calls another function and passes a query string to the end of the URL.

我将如何完成以下操作 -

How would I accomplish the following --

if my_videos:
    return render(request, template, {kwargs}) + "?filter=others&sort=newest"

注意:我不在乎我是否使用render,它的用法只是指出我试图完成谢谢。

Note: I do not care if I use render or not, its use is merely to point out what I'm trying to accomplish. Thank you.

推荐答案

传递模板中的查询字符串:

Pass the query string in the template:

<a href="{% url my_videos %}?filter=others&sort=newest">My Videos</a>

这篇关于在django中追加一个查询字符串到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆