Created
February 23, 2011 04:07
-
-
Save yuchant/839996 to your computer and use it in GitHub Desktop.
A Terrible Idea
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
class ModelAdmin(admin.ModelAdmin) | |
""" | |
Refrain from prolonged exposure. | |
""" | |
def render_change_form(self, request, context, *args, **kwargs): | |
def get_queryset(original_func): | |
import inspect, itertools | |
def wrapped_func(): | |
if inspect.stack()[1][3] == '__iter__': | |
return itertools.repeat(None) | |
return original_func() | |
return wrapped_func | |
for formset in context['inline_admin_formsets']: | |
formset.formset.get_queryset = get_queryset(formset.formset.get_queryset) | |
return super(OrderAdmin, self).render_change_form(request, context,*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment