-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
50 lines (41 loc) · 1.33 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from django.forms import ModelForm, PasswordInput
from newblog.models import Blog, Tag
from django import forms
from django.contrib.auth.models import User
# class UserForm(ModelForm):
# class Meta:
# model = User
# widgets = {
# 'password': PasswordInput(),
# }
class BlogForm(forms.Form):
title = forms.CharField(required=True, label='title', max_length=100)
content = forms.CharField(widget=forms.Textarea())
class TagForm(forms.Form):
tag_name = forms.CharField()
class LoginForm(forms.Form):
username = forms.CharField(
required=True,
label=u"username",
error_messages={'required': 'Please Input Username'},
widget=forms.TextInput(
attrs={
'placeholder':u"Username",
}
),
)
password = forms.CharField(
required=True,
label=u"password",
error_messages={'required': u'Please Input Password'},
widget=forms.PasswordInput(
attrs={
'placeholder':u"Password",
}
),
)
def clean(self):
if not self.is_valid():
raise forms.ValidationError(u"Please input username and password")
else:
cleaned_data = super(LoginForm, self).clean()