Download apps/categories/models.py from ecocyclehub-capstone-dicoding/ecocyclehub-api: direct link, hf CLI and curl.
- Browser
- Download file 678 Bytes
-
https://huggingface.co/spaces/ecocyclehub-capstone-dicoding/ecocyclehub-api/resolve/main/apps/categories/models.py
- Command line
-
hf download hf://spaces/ecocyclehub-capstone-dicoding/ecocyclehub-api/apps/categories/models.py
-
curl -L -o models.py https://huggingface.co/spaces/ecocyclehub-capstone-dicoding/ecocyclehub-api/resolve/main/apps/categories/models.py
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 | |