What's best practice to check if an object is part of a ManyToMany relationship in Django
- by PhilGo20
from an instance of Site with a ManyToMany relationship to Kiosk, i'd like to check if a Kiosk object is part of the relationship.
I could do
self.apps.get(id=app_id).exists() and check if True
or
self.apps.get(id=app_id) and catch the ObjectDoesNotExist error
or
self.apps.filter(id=app_id) and check if True
If I have to catch a…