django - 如何在 django 模板语言的 url 中发送两个参数?
问题描述
{% url 'start' commission.id applie.id %}
像上面的代码一样,我正在尝试发送两个模型 ID,但我不知道它的正确结构。上面的代码不起作用。
path('start/<int:post_id>', views.start, name="start"),
def start(request,post_id):
如果我得到两个括号,我应该如何修改上面的 url 并查看代码?
解决方案
试着走这条路。。
在 urls.py 中——
path('profile/<name> <email>', views.profile, name='profile'),
#As path have space, it will take %20 there,
#you can change it accordingly. best to use '-' instead of space
#http://example.com/profile/myname%20myemail@example.com
在链接中——
href="{% url 'profile' name='myname' email='myemail@example.com' %}"
在views.py中——
@login_required(login_url="login")
def profile(request, name, email):
return render(request, "profile.html", {'name': name, 'email':email})
推荐阅读
- spring-boot - 如何将相对路径参数与 Spring Boot/picocli 可执行 jar 一起使用?
- javascript - 根据表格列中的内容过滤表格
- jquery - 在具有不同 URL 的两个选项卡之间共享数据
- flutter - 颤振发布请求上的请求有效负载输入无效
- webassembly - 我可以在客户端发布 Webassembly 或将其作为 Assemblyscript 运行吗?
- oracle-apex - 在 oracle apex 18.1 中升级 Web 应用程序
- jenkins - Jenkins Active Choices 参考参数不显示返回的结果
- java - Appium Android:在Java中按元素ID查找元素
- javascript - 选择某个收音机时更新变量
- python - 如何使用 Python 抓取“sorting_1”类中的内容?