diff --git a/nummi/main/models.py b/nummi/main/models.py index 3ddc8f8..53c4a25 100644 --- a/nummi/main/models.py +++ b/nummi/main/models.py @@ -3,7 +3,7 @@ import pathlib import uuid from django.conf import settings -from django.core.validators import FileExtensionValidator +from django.core.validators import FileExtensionValidator, validate_slug from django.db import models, transaction from django.urls import reverse from django.utils.translation import gettext as _ @@ -34,7 +34,10 @@ class Account(CustomModel): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=64, default=_("Account"), verbose_name=_("Name")) icon = models.CharField( - max_length=64, default="building-columns", verbose_name=_("Icon") + max_length=64, + default="building-columns", + verbose_name=_("Icon"), + validators=[validate_slug], ) def __str__(self): @@ -76,7 +79,12 @@ class Category(CustomModel): name = models.CharField( max_length=64, default=_("Category"), verbose_name=_("Name") ) - icon = models.CharField(max_length=64, default="folder", verbose_name=_("Icon")) + icon = models.CharField( + max_length=64, + default="folder", + verbose_name=_("Icon"), + validators=[validate_slug], + ) budget = models.BooleanField(default=True, verbose_name=_("Budget")) def __str__(self):