mirror of
https://github.com/django/django.git
synced 2024-11-24 02:47:35 +01:00
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.")
|