def save(self, commit=True):
instance = super(CategoryForm, self).save(commit=False)
instance.created_by = self.user
instance.title = self.cleaned_data['title']
if str(self.cleaned_data['is_votable']) == 'True':
instance.is_votable = True
else:
instance.is_votable = False
if str(self.cleaned_data['is_active']) == 'True':
instance.is_active = True
else:
instance.is_active = False
if not self.instance.id:
instance.slug = slugify(self.cleaned_data['title'])
if commit:
instance.save()
return instance
评论列表
文章目录