Django:管理员的永久链接
我知道到达对象的链接模板如下所示:
"{{ domain }}/{{ admin_dir }}/{{ appname }}/{{ modelname }}/{{ pk }}"
是否有内置方法来获取对象的永久链接?
from django.contrib import admin
def get_admin_permalink(instance, admin_site=admin.site):
# returns admin URL for instance change page
raise NotImplemented
编辑
它似乎在 v1.1 admin
已命名 URL。 不幸的是它还没有发布。
I know the link template to reach an object is like following:
"{{ domain }}/{{ admin_dir }}/{{ appname }}/{{ modelname }}/{{ pk }}"
Is there a way built-in to get a permalink for an object?
from django.contrib import admin
def get_admin_permalink(instance, admin_site=admin.site):
# returns admin URL for instance change page
raise NotImplemented
EDIT
It seems in v1.1 admin
has named URLs. Unfortunately it's not yet released.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1.1 已发布,文档就在这里: http ://docs.djangoproject.com/en/dev/ref/contrib/admin/#admin-reverse-urls
http://docs.djangoproject.com/en/dev/ref /templates/builtins/#url
我也使用过它,每当您获取现有的管理 url 时都必须指定管理名称空间。
在 1.1 中,每当获取管理 URL 时,您都必须指定“admin”命名空间。
1.1 is out, the doc is right here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#admin-reverse-urls
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
I also used it a bit, the admin namespace will have to be specified whenever you are fetching an existing admin url.
In 1.1, whenever an admin url is fetched, you'll have to specify the 'admin' namespace.