Add sorting, enforce foreign keys

This commit is contained in:
2022-07-15 17:28:44 +02:00
parent 273225f919
commit e55f953c8a
10 changed files with 103 additions and 12 deletions

View File

@@ -108,12 +108,14 @@ def tag_pre_save(sender, instance, **kwargs):
class RollingStockType(models.Model):
type = models.CharField(max_length=64)
order = models.PositiveSmallIntegerField()
category = models.CharField(
max_length=64, choices=settings.ROLLING_STOCK_TYPES
)
class Meta(object):
unique_together = ("category", "type")
ordering = ["order"]
def __str__(self):
return "{0} {1}".format(self.type, self.category)