标签 url 模板 django 不起作用

发布于 2024-09-28 14:19:26 字数 541 浏览 3 评论 0原文

我尝试在我的项目中实现 url 模板标记。
我有一个按钮,允许用户保存他所看到的数据。
所以这个按钮的url是这样的:

(2)url(r'^nameviews/download/$', 'my.path.is.this.to.download' name="load"),

模板:

<a href="{% url load %}">Download</a>

显示信息的页面的url,按钮所在的位置是:

(1)(r'^nameviews/$', path.to.page),

但是当我尝试单击该按钮时(它应该出现url 2)它没有打开包含数据的文件,但给了我与主页 (1) 相同的 url,

html 验证器给我一个错误,

    <a href="">   

似乎它无法识别 url 标签。

有人有什么想法吗?

I trying to implement the url template tag into my project.
I have a button that allows the user to save the data he is seeing.
So the url of this button is this:

(2)url(r'^nameviews/download/

template:

<a href="{% url load %}">Download</a>

the url of the page that shows the information, and where the button is located is:

(1)(r'^nameviews/

but when I tried to click on the button (it should appear the url 2)it doesn't open the file with the data but instead gives me the same url that the main page (1)

the html validator gives me a error on the

    <a href="">   

It seems it doesn't recognize the url tag.

Anyone has any idea?

, 'my.path.is.this.to.download' name="load"),

template:


the url of the page that shows the information, and where the button is located is:


but when I tried to click on the button (it should appear the url 2)it doesn't open the file with the data but instead gives me the same url that the main page (1)

the html validator gives me a error on the


It seems it doesn't recognize the url tag.

Anyone has any idea?

, path.to.page),

but when I tried to click on the button (it should appear the url 2)it doesn't open the file with the data but instead gives me the same url that the main page (1)

the html validator gives me a error on the

It seems it doesn't recognize the url tag.

Anyone has any idea?

, 'my.path.is.this.to.download' name="load"),

template:

the url of the page that shows the information, and where the button is located is:

but when I tried to click on the button (it should appear the url 2)it doesn't open the file with the data but instead gives me the same url that the main page (1)

the html validator gives me a error on the

It seems it doesn't recognize the url tag.

Anyone has any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無處可尋 2024-10-05 14:19:26

解决了!我真的不明白发生了什么,因为我没有改变太多,但应该是一些愚蠢的错误。

对不起!
无论如何,谢谢:)

编辑

请注意网址的顺序。在 urls.py 尝试以下顺序:

url(r'^nameviews/download/

如果视图相同,则 name_of_view 相等

, name_of_view, name="load"), url(r'^nameviews/

如果视图相同,则 name_of_view 相等

, name_of_view, name="first page"),

如果视图相同,则 name_of_view 相等

Resolved! I didn't really understood what's happen because I didn't change much but should have been some silly mistake.

Sorry!
Thanks any way :)

EDIT

Be careful with the order of the urls. At urls.py try this order:

url(r'^nameviews/download/

name_of_view is equal if the view is the same

, name_of_view, name="load"), url(r'^nameviews/

name_of_view is equal if the view is the same

, name_of_view, name="first page"),

name_of_view is equal if the view is the same

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文