Add models for graph app
This commit is contained in:
parent
ec92e0b089
commit
ee12a15b5e
@ -1,3 +1,32 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
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}"
|
||||
|
Loading…
Reference in New Issue
Block a user