当前位置: 首页>>代码示例>>Python>>正文


Python ModelForm.save方法代码示例

本文整理汇总了Python中django.forms.ModelForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python ModelForm.save方法的具体用法?Python ModelForm.save怎么用?Python ModelForm.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.forms.ModelForm的用法示例。


在下文中一共展示了ModelForm.save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
 def save(self):
     if self.is_valid():
         au = auth.models.User.objects.create_user(
             username=self.cleaned_data["email"],
             email=self.cleaned_data["email"],
             password=self.cleaned_data["password"],
         )
         self.instance.user = au
         self.instance.user.first_name = self.cleaned_data["first_name"]
         self.instance.user.last_name = self.cleaned_data["last_name"]
         self.instance.user.save()
         ModelForm.save(self)
开发者ID:fastfrwrd,项目名称:Victr,代码行数:14,代码来源:forms.py

示例2: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
    def save(self, commit=True):
        # we want to bypass UserCreationForm's save.
        user = ModelForm.save(self, commit=False)

        # only set a pass if the form is filled
        if self.cleaned_data['password1']:
            user.set_password(self.cleaned_data["password1"])
        if commit:
            user.save()
        return user
开发者ID:WPI-LNL,项目名称:lnldb,代码行数:12,代码来源:forms.py

示例3: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
    def save(self, commit=True):
        # Get the saved Group instance
        group = ModelForm.save(self, True)
        GroupItem.objects.filter(group=group, item__wisher=self.user).delete()

        group_items = []
        for item in self.cleaned_data['items']:
            print "creating intermediate groupitems[item] for %s" % item
            group_items.append(GroupItem(group=group, item=item).save())

        return group_items
开发者ID:pclements12,项目名称:PyWishlist,代码行数:13,代码来源:GroupItemsForm.py

示例4: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
 def save(self, commit=True):
     added_sites = set()
     msc = ModelForm.save(self, commit)
     for site in self.cleaned_data['active_sites']:
         added_sites.add(site)
     if msc.pk:
         if set(added_sites) != set(msc.seosite_set.all()):
             msc.seosite_set = added_sites
     else:
         msc.save()
         msc.seosite_set = added_sites
     return msc
开发者ID:AstroMatchDynamics,项目名称:MyJobs,代码行数:14,代码来源:admin.py

示例5: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
 def save(self, **args):
     res = ModelForm.save(self, **args)
     for f in FlagType.objects.all():
         fv = self.data[f.name]
         d = {'item': self.instance.id, 'type': f.id, 'value': fv}
         try:
             fg = Flag.objects.get(item=self.instance.id, type=f.id)
         except Flag.DoesNotExist:
             fg = Flag()
         ff = FlagForm(d, instance=fg)
         fv = ff.save()
         setattr(res, f.name, fv)
     return res
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:15,代码来源:forms.py

示例6: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
    def save(self, commit=True):
        # Get the unsaved Item instance
        instance = ModelForm.save(self, False)

        # Prepare a 'save_m2m' method for the form,
        old_save_m2m = self.save_m2m

        def new_save_m2m():
            old_save_m2m()
            # This is where we actually link the item with groups
            instance.wishlistgroup_set.clear()
            for group in self.cleaned_data['groups']:
                print "creating intermediate groupitems for %s" % group
                GroupItem(item=instance, group=group).save()
                # instance.wishlistgroup_set.add(group)

        self.save_m2m = new_save_m2m

        # Do we need to save all changes now?
        if commit:
            instance.save()
            self.save_m2m()

        return instance
开发者ID:pclements12,项目名称:PyWishlist,代码行数:26,代码来源:ItemForm.py

示例7: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
 def save(self, *args, **kwargs):
     inst = ModelForm.save(self, *args, **kwargs)
     return inst
开发者ID:swansong,项目名称:labgeeksrpg,代码行数:5,代码来源:forms.py

示例8: save

# 需要导入模块: from django.forms import ModelForm [as 别名]
# 或者: from django.forms.ModelForm import save [as 别名]
 def save(self, *args, **kwargs):
     inst = ModelForm.save(self, *args, **kwargs)
     inst.item.item.save()
     newIssueSignal.send(sender=inst, instance=inst, created =True, data=self.data)
     return inst
开发者ID:abztrakt,项目名称:labtracker,代码行数:7,代码来源:forms.py


注:本文中的django.forms.ModelForm.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。