I have 3 apps products, sales, purchases. each app has a correspondingly named Model class, Product, Sale, and Purchase.
products/models.py
class Product(models.Model):
Name = models.CharField(max_length=32)
sales/models.py
class Sale(models.Model):
Product = models.ForeignKey('products.Product', on_delete=models.CASCADE)
purchases/models.py
class Purchase(models.Model):
Product = models.ForeignKey('products.Product', on_delete=models.CASCADE)
And I decided to make custom managers for the Model classes so that I can keep all the logic in the model files (by overriding objects attr for each class) when I'm writing the methods in the custom manager I imported Sale model In products.models and Product model in sales.models which creates a circular reference, I was able to get away with it by performing the imports in the methods themselves but I remember reading online that circular imports are sign of bad code writing.
So my question is how can I avoid circular imports in this case and have access to the Product Model in sales.models and Sale in products.models.