def objects_for_user(self, user, qs=None, xmin__lte=None):
qs = self.get_queryset(qs)<EOL>user_rels = self.user_rel<EOL>if user_rels:<EOL><INDENT>if user is None:<EOL><INDENT>return qs.none()  <EOL><DEDENT>if isinstance(user_rels, basestring):<EOL><INDENT>user_rels = [user_rels]<EOL><DEDENT>user_filter = None<EOL>meta = self.model._meta<EOL>for user_rel in user_rels:<EOL><INDENT>name, rel = (user_rel.split('<STR_LIT>', <NUM_LIT:1>) + [None])[:<NUM_LIT:2>]<EOL>field = meta.pk if name == '<STR_LIT>' else meta.get_field(name)<EOL>if field.related_model is not None:<EOL><INDENT>filter_obj = Q(**{<EOL>'<STR_LIT>' % name: field.related_model.objects.filter(<EOL>**{rel or '<STR_LIT>': user}<EOL>).values('<STR_LIT>'),<EOL>})<EOL><DEDENT>else:<EOL><INDENT>filter_obj = Q(**{str(user_rel): user})<EOL><DEDENT>if user_filter is None:<EOL><INDENT>user_filter = filter_obj<EOL><DEDENT>else:<EOL><INDENT>user_filter |= filter_obj<EOL><DEDENT><DEDENT>qs = qs.filter(user_filter).distinct()<EOL><DEDENT>if xmin__lte is not None:<EOL><INDENT>qs = qs.extra(<EOL>where=["<STR_LIT>"],<EOL>params=[xmin__lte],<EOL>)<EOL><DEDENT>return qs<EOL>
Find objects in queryset related to specified user.