first commit

This commit is contained in:
javad committed 2026-06-15 10:57:28 +03:30
commit 3e4574dcdd
163 files changed
+3559

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
from django.db import models
from apps.emtiyazat.models import ArzeshEmtiyaz as ArzeshEmtiyazModel
# Create your models here.
class ProductCategory(models.Model):
name = models.CharField(max_length=50, null=False, blank=False)
image = models.ImageField(upload_to='product_category/', null=True, blank=True)
is_enable = models.BooleanField(default=True)
def __str__(self):
return self.name
class Product(models.Model):
category = models.ForeignKey(ProductCategory, on_delete=models.CASCADE, related_name='product_category')
name = models.CharField(max_length=50, null=False, blank=False)
price = models.PositiveIntegerField(null=False, blank=False)
emtiyaz = models.PositiveIntegerField(null=False, blank=False)
desc = models.TextField(null=True, blank=True)
image = models.ImageField(upload_to='product/', null=True, blank=True)
is_enable = models.BooleanField(default=True)
quantity = models.PositiveIntegerField(null=True, blank=True)
@property
def get_emtiyaz(self):
arzesh_obj = ArzeshEmtiyazModel.objects.filter().last()
return self.price / arzesh_obj.price
def __str__(self):
return self.name