from django.db import models from market.models import Product class Transaction(models.Model): product = models.ForeignKey( Product, on_delete=models.CASCADE, related_name="transactions" ) price = models.IntegerField() created_at = models.DateTimeField(auto_now_add=True) class Meta: ordering = ["-created_at"] def __str__(self): return f"{self.product} : {self.price}" class MonthlyTransaction(models.Model): product = models.ForeignKey( Product, on_delete=models.CASCADE, related_name="monthly_transactions" ) year = models.IntegerField() month = models.IntegerField() price = models.IntegerField() class Meta: ordering = ["-year", "-month"] def __str__(self): return f"{self.product} : {self.year}-{self.month}"