#NEWLINE# def object_filter( request , model = None , queryset = None , template_name = None , extra_context = None , context_processors = None , filter_class = None ) : #NEWLINE# #INDENT# if ( ( model is None ) and ( filter_class is None ) ) : #NEWLINE# #INDENT# raise TypeError ( 'object_filter must be called with either model or filter_class' ) #NEWLINE# #UNINDENT# if ( model is None ) : #NEWLINE# #INDENT# model = filter_class . _meta . model #NEWLINE# #UNINDENT# if ( filter_class is None ) : #NEWLINE# #INDENT# meta = type ( 'Meta' , ( object , ) , { #NEWLINE# #INDENT# 'model' : model , #NEWLINE# #UNINDENT# } ) #NEWLINE# filter_class = type ( ( '%sFilterSet' % model . _meta . object_name ) , ( FilterSet , ) , { #NEWLINE# #INDENT# 'Meta' : meta , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# filterset = filter_class ( ( request . GET or None ) , queryset = queryset ) #NEWLINE# if ( not template_name ) : #NEWLINE# #INDENT# template_name = ( '%s/%s_filter.html' % ( model . _meta . app_label , model . _meta . object_name . lower ( ) ) ) #NEWLINE# #UNINDENT# c = RequestContext ( request , { #NEWLINE# #INDENT# 'filter' : filterset , #NEWLINE# #UNINDENT# } ) #NEWLINE# if extra_context : #NEWLINE# #INDENT# for ( k , v ) in extra_context . iteritems ( ) : #NEWLINE# #INDENT# if callable ( v ) : #NEWLINE# #INDENT# v = v ( ) #NEWLINE# #UNINDENT# c [ k ] = v #NEWLINE# #UNINDENT# #UNINDENT# return render_to_response ( template_name , c )