class PageForm forms ModelForm title forms CharField label Заголовок w

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class PageForm(forms.ModelForm):
title = forms.CharField(label=u"Заголовок", widget=forms.TextInput())
slug = forms.CharField(label=u"URL", required=False, widget=forms.HiddenInput())
template = forms.ChoiceField(label=u"Шаблон", required=False, choices=settings.PAGE_TEMPLATES)
body = forms.CharField(widget=forms.Textarea)
class Meta:
model = Page
def clean_slug(self):
slug = slugify(translify(self.cleaned_data['title']))
target = self.data.get('target', None)
position = self.data.get('position', None)
return slug