Skip to content

Instantly share code, notes, and snippets.

@yuchant
Created February 23, 2011 04:07
Show Gist options
  • Save yuchant/839996 to your computer and use it in GitHub Desktop.
Save yuchant/839996 to your computer and use it in GitHub Desktop.
A Terrible Idea
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