I have inherited a weird table structure:
class Customer(models.Model):
account_number = models.CharField()
class Subscription(models.Model):
account_number = models.CharField()
So the Customer and Subscription models are linked by their account numbers. Each customer can have multiple subscriptions, and each subscription can have multiple customers, but there is no intermediary table; there is no "Account" table. How do I handle this sort of thing? If I have a Subscription queryset, how do I go about getting the corresponding Customer queryset without doing a horribly long query like
customers = Customer.objects.filter(account_number__in=list(subscriptions.values_list('account_number', flat=True)))
I'm trying to avoid this because it would generate a massive query that would take a very long time to execute.