Created
July 9, 2010 08:07
-
-
Save rctay/469214 to your computer and use it in GitHub Desktop.
[django] admin view wrapper cum url() factory method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Wraps a view in AdminSite.admin_view() and returns a url() tuple constructed | |
from the view's name. | |
""" | |
from django.conf.urls.defaults import url | |
def wrap_admin_view(modeladmin, view_func): | |
view = view_func.__name__ | |
meta = modeladmin.model._meta | |
return url( | |
r'^%s/$' % view, | |
modeladmin.admin_site.admin_view(view_func), | |
name='%s_%s_%s' % (meta.app_label, meta.module_name, view), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment