from django import forms from .models import Tag class TagForm(forms.ModelForm): class Meta: model = Tag fields = ["name", "color"] widgets = {"color": forms.TextInput(attrs={"type": "color"})} class AddTagToArticleForm(forms.Form): """Freeform tag-name entry — assigning an unknown name creates that tag for the user, so there's one flow instead of "create tag" then "assign tag" as two separate steps.""" tag_name = forms.CharField(max_length=100)