created apps.dashboard.forms & commensurate apps.dashboard.tests.test_forms; new ItemForm() ModelForm & EMPTY_ITEM_ERROR constant

This commit is contained in:
Disco DeDisco
2026-01-19 22:01:33 -05:00
parent 5af5ff55fa
commit 0014d9124a
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
from django import forms
from .models import Item
EMPTY_ITEM_ERROR = "You can't have an empty list item"
class ItemForm(forms.models.ModelForm):
class Meta:
model = Item
fields = ("text",)
widgets = {
"text": forms.widgets.TextInput(
attrs={
"placeholder": "Enter a to-do item",
"class": "form-control form-control-lg",
}
),
}
error_messages = {"text": {"required": EMPTY_ITEM_ERROR}}