27 lines
586 B
Python
27 lines
586 B
Python
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.")
|