2016-09-29 38 views
2

裏面我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 

這將使以下網址:

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

將執行功能customfunc2。我現在的問題是如何通過執行reverse來引用此URL?

我想:

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

但這些都不工作。

回答

1

你有name='customfunc23',它是在admin應用程序,所以你應該使用:

reverse('admin:customfunc23')