django/tests/generic_views/forms.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
586 B
Python
Raw Normal View History

from django import forms
from .models import Author
class AuthorForm(forms.ModelForm):
name = forms.CharField()
slug = forms.SlugField()
class Meta:
model = Author
fields = ["name", "slug"]
class ContactForm(forms.Form):
name = forms.CharField()
message = forms.CharField(widget=forms.Textarea)
class ConfirmDeleteForm(forms.Form):
confirm = forms.BooleanField()
def clean(self):
cleaned_data = super().clean()
if "confirm" not in cleaned_data:
raise forms.ValidationError("You must confirm the delete.")