from django.db import models
class Person(models.Model):
# <fields>
def has_device(self):
# ***prefetch related phones and laptops***
if self.phone_set.first() or self.laptop_set.first():
return True
return False
class Laptop(models.Model):
owner = models.ForeignKey(Person)
# <fields>
class Phone(models.Model):
owner = models.ForeignKey(Person)
# <fields>