I have two models like this:
class Type1Profile(models.Model):
user = models.OneToOneField(User, unique=True)
...
class Type2Profile(models.Model):
I am using a combination of has_attr and is None:
class DriverLocation(models.Model):
driver = models.OneToOneField(Driver, related_name='location', on_delete=models.CASCADE)
class Driver(models.Model):
pass
@property
def has_location(self):
return not hasattr(self, "location") or self.location is None