elvandry13's picture
Clean repository history
c2eae0d
Raw History Blame Contribute Delete
678 Bytes
import uuid
from django.db import models
from django.db.models.functions import Lower
class Category(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=100)
price_per_kg = models.PositiveIntegerField()
point_per_kg = models.PositiveIntegerField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
constraints = [
models.UniqueConstraint(
Lower("name"),
name="uq_categories_name_ci"
)
]
def __str__(self):
return self.name