Python 反向模型管理自定义URL
在我的Python 反向模型管理自定义URL,python,django,python-2.7,django-admin,Python,Django,Python 2.7,Django Admin,在我的admin.py文件中,我有: def get_urls(self): urls = super(TextAdmin, self).get_urls() my_urls = patterns('', url( r'customfunc1', customfunc2, name='customfunc23', ), ) return my_urls + ur
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
。我现在的问题是,如何通过执行反向操作来引用此URL
我试过:
reverse("admin:text_customfunc1")
reverse("admin:text_customfunc2")
reverse("admin:text_customfunc3")
reverse("text:customfunc1")
但是这些都不起作用。您有name='customfunc23'
,并且它在admin
应用程序中,因此您应该使用:
reverse('admin:customfunc23')