反向自定义 django 管理站点 url?
有没有办法反转添加到自定义 django AdminSite 的 URL,例如
class MyAdminSite(AdminSite):
def get_urls(self):
urls = super(MyAdminSite, self).get_urls()
my_urls = patterns('',
url(r'some_view/$',self.admin_view( SomeView.as_view()), name='some_view' ),
)
return my_urls + url
myadmin = MyAdminSite(app_name='my_admin')
url(r'^admin/', include(my_admin.urls)),
如何反转 some_view
Is there a way to reverse URLs added to a custom django AdminSite, for example
class MyAdminSite(AdminSite):
def get_urls(self):
urls = super(MyAdminSite, self).get_urls()
my_urls = patterns('',
url(r'some_view/
How do i reverse some_view
,self.admin_view( SomeView.as_view()), name='some_view' ),
)
return my_urls + url
myadmin = MyAdminSite(app_name='my_admin')
url(r'^admin/', include(my_admin.urls)),
How do i reverse some_view
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:{% url admin:some_view %}
Try: {% url admin:some_view %}
或者,如果您已经为管理站点定义了一个名称,如下所示:
可以通过使用自定义站点名称应用命名空间来反转 url,如下所示:
alternatively, if you've defined a name for your admin site like so:
reversing the url would be done by applying namespacing using your custom sites' name, like so: