23 lines
729 B
Python
23 lines
729 B
Python
from django.db import models
|
|
from django_extensions.db.models import ModificationDateTimeField
|
|
|
|
|
|
class Teil(models.Model):
|
|
name = models.TextField("Name of the part", null=False, blank=False)
|
|
modified = ModificationDateTimeField("last changed")
|
|
|
|
class Meta:
|
|
constraints = [
|
|
models.UniqueConstraint(fields=["name"], name="unique_names"),
|
|
]
|
|
indexes = [
|
|
models.Index(fields=["modified"], name="idx_modified"),
|
|
]
|
|
|
|
verbose_name = "Teil"
|
|
verbose_name_plural = "Teile"
|
|
ordering = ["-modified"]
|
|
|
|
def __str__(self) -> str:
|
|
modified = self.modified.isoformat(timespec="seconds")
|
|
return f"{self.name} (last change: {modified})"
|