python - 使用 django 和 nginx 解析 URL
问题描述
所以我正在构建一个 django web 应用程序并尝试使用 nginx 部署它。
langing 页面加载,但是当我单击链接时,我收到 nginx 400 Bad Request 错误。
浏览器中的 url 将如下所示:
"GET /%7B$%%20url%20'members:member_login'%20%%7D HTTP/1.1" 400 173 "-" "-" "-"
但是,如果我进入浏览器并手动删除多余的字符以获得:
/url'members:member_login'
然后它可以正常工作并呈现页面。有谁知道我可以在我的 nginx 配置文件或 django 代码中添加什么来解决这个问题?它已经难倒了我 2 周。
解决方案
This looks like an error in your template: %7b
is {
, %20
is . I think you might have a typo in the
href
attribute of the link you clicked, could it be:
<a href="{$% url 'members:member_login' %}">...
instead of
<a href="{% url 'members:member_login' %}">...
With these kinds of errors, always make sure to inspect the actual html source in your browser (right click -> 'View page source' in chrome).
推荐阅读
- javascript - 在节点 js 中向多个订阅客户端发送电子邮件
- c# - 如何将 System.Data.OleDb 与.NET Core 连接?
- c++ - 找不到匹配的运算符删除;如果初始化抛出异常,内存将不会被释放
- python-3.x - 循环选择行,直到达到目标数字
- python - 无法将类型“ndarray”转换为分子/分母
- angular - Angular Reactive Form 值为空
- hadoop - 应用逻辑后,正则表达式模式在 pyspark 中不起作用
- html - 为什么我的属性选择器不起作用?
- mongodb - 如何在没有规范扩展 JSON 添加的情况下获取 DecodeBytes() 输出
- ssas - MDX 查询中的 And-Or