gpt4 book ai didi

python - 反向模型管理员自定义 URL

转载 作者:太空宇宙 更新时间:2023-11-04 05:22:49 24 4
gpt4 key购买 nike

在我的 admin.py 文件中,我有:

def get_urls(self):
urls = super(TextAdmin, self).get_urls()
my_urls = patterns('',
url(
r'customfunc1',
customfunc2,
name='customfunc23',
),
)
return my_urls + urls

这将启用以下 URL:

http://localhost:8000/admin/text/customfunc1

这将执行函数 customfunc2。我现在的问题是如何通过执行 reverse 来引用此 URL?

我试过:

reverse("admin:text_customfunc1")
reverse("admin:text_customfunc2")
reverse("admin:text_customfunc3")
reverse("text:customfunc1")

但这些都不起作用。

最佳答案

你有 name='customfunc23',它在 admin 应用程序中,所以你应该使用:

reverse('admin:customfunc23')

关于python - 反向模型管理员自定义 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39779545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com