Decorating all django admin views (1.4+)

北慕城南 提交于 2019-12-10 17:28:31

问题


There used to be a neat trick for Django versions prior to 1.4 to decorate all views within the admin:

urlpatterns = patterns('',
    (r'^admin/(.*)', my_decorator(lambda *args: admin.site.root(*args))),
)

This no longer works as root is deprecated. I have found some alternatives, but they seem pretty verbose compared to what I had. Is there still a hook to do this?


回答1:


Decorate every view in a url tree

http://djangosnippets.org/snippets/2607/



来源:https://stackoverflow.com/questions/14537829/decorating-all-django-admin-views-1-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!