Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /FastJango_FastJango /fastjango /templates /app_template /models.py
| """ | |
| Models for {{app_name}} app. | |
| """ | |
| from fastjango.db import models | |
| from fastjango.core.exceptions import ValidationError | |
| class {{app_name_camel}}Model(models.Model): | |
| """ | |
| Example model for {{app_name}} app. | |
| """ | |
| name = models.CharField(max_length=100) | |
| description = models.TextField(blank=True, null=True) | |
| created_at = models.DateTimeField(auto_now_add=True) | |
| updated_at = models.DateTimeField(auto_now=True) | |
| class Meta: | |
| ordering = ["-created_at"] | |
| verbose_name = "{{app_name_camel}}" | |
| verbose_name_plural = "{{app_name_camel}}s" | |
| def __str__(self): | |
| return self.name | |
| def clean(self): | |
| """ | |
| Custom validation logic. | |
| """ | |
| if self.name.lower() == "test": | |
| raise ValidationError({"name": "Name cannot be 'test'"}) | |
| def save(self, *args, **kwargs): | |
| self.clean() | |
| super().save(*args, **kwargs) |
Xet Storage Details
- Size:
- 941 Bytes
- Xet hash:
- 2a5f89d04d88f2b02a4f05d3a83d3bc79729a5bfec5062ee736f40bb9b127906
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.