﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25787	Add existence checks for related database sets on managers	Justus Adam	Anderson Resende	"I have recently had to check for presence of a particular object in a set of related objects (either ManyToMany or ForeignKey) and I found it unnecessary cumbersome not to be able to use the 
{{{in}}} operator.

I propose to add an implementation of the {{{__contains__}}} method to the {{{ManyRelatedManager}}} object which executes something like the following query:

{{{ 
def __contains__(self, obj):
    return self.filter(id=obj.id).exists()
}}}

which would enable the following sample behaviour:

{{{
my_student = request.user.student
my_course = Course.objects.get(id=course_id)
is_teacher = my_student in my_course.teachers
}}}
"	New feature	closed	Database layer (models, ORM)	1.8	Normal	wontfix	ManyToMany, contains, in		Unreviewed	0	0	0	0	1	0
