forms.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:django-simple-forum 作者: MicroPyramid 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号