#NEWLINE# def inrange_filter( fld , rng , **kw ) : #NEWLINE# #INDENT# 'Assuming a database model with a field named `fld`, return a Q\n    object to select those rows whose `fld` value is not null and\n    within the given range `rng`.  `rng` must be a tuple or list with\n    two items.\n\n    ' #NEWLINE# assert ( rng [ 0 ] <= rng [ 1 ] ) #NEWLINE# kw [ ( rng + '__isnull' ) ] = False #NEWLINE# kw [ ( fld + '__gte' ) ] = rng [ 0 ] #NEWLINE# kw [ ( fld + '__lte' ) ] = rng [ 1 ] #NEWLINE# return Q ( ** kw )