mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
3a45fea083
Thanks to Mariusz Felisiak for review. Co-authored-by: Demetris Stavrou <demestav@gmail.com> Co-authored-by: Caroline Simpson <github@hoojiboo.com>
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.')
|