HiPhone_BE/graph/models.py

33 lines
825 B
Python
Raw Permalink Normal View History

2023-05-04 11:06:04 +09:00
from django.db import models
2023-05-25 14:50:20 +09:00
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}"