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
You can tell me to use whatever works and that'll be a valid answer ;-)
I would use
self.apps.filter(id=app_id).exists()
What's wrong with that?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With