Created
March 2, 2012 00:28
-
-
Save linuxfood/1954260 to your computer and use it in GitHub Desktop.
Django auto-generated admin actions
This file contains hidden or 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
def puser_setcompanyroutines(): | |
routines = [] | |
for c in Company.objects.all(): | |
fn = lambda modeladmin, request, queryset: queryset.update(company=c) | |
# WTF, you say? Yep. That's because django actually cares about the NAME | |
# of the function handles you pass it in the actions list. Stupid. | |
fn.__name__ = "set_company_%d" % c.id | |
fn.short_description = "Set selected to company %s" % c.name | |
routines.append(fn) | |
return routines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment