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


Python FormView.form_valid方法代码示例

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


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

示例1: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
    def form_valid(self, form):
        response = FormView.form_valid(self, form)

        # After successful login, save dict of user data given by data server
        # API into JWT cookie. Also save session id of session from data
        # server, for use when making requests to data server via Rabbit.
        # Note UI server and admin server have different secrets and domains.
        jwt_val = jwt.encode(
            {
                "user": form.user,
                "session": form.session_cookie.value
            },
            settings.COOKIE_SECRET,
        )
        expires = datetime.fromtimestamp(form.session_cookie.expires)\
                          .strftime('%a, %d %b %Y %H:%M:%S')
        kwargs = {
            'value': jwt_val,
            'expires': expires,
            'secure': settings.SESSION_COOKIE_SECURE,
            'httponly': True,
            'domain': cookie_domain(),
        }

        response.set_cookie("alice", **kwargs)
        return response
开发者ID:UKTradeInvestment,项目名称:export-wins-ui,代码行数:28,代码来源:views.py

示例2: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     """Create operation with optional splits."""
     self.form = form
     date = form.cleaned_data['date']
     if form.cleaned_data['splits'] == 1:
         models.Operation.objects.create(
             account=form.cleaned_data['account'],
             transaction=form.cleaned_data['transaction'],
             date=date,
             amount=form.cleaned_data['amount'],
             description=form.cleaned_data['description'],
         )
     else:
         splits = split_amount(
             form.cleaned_data['amount'],
             form.cleaned_data['splits'])
         for position, amount in enumerate(splits):
             description = u'{desc} ({total}/{splits}, part {pos})'.format(
                 desc=form.cleaned_data['description'],
                 pos=position + 1,
                 splits=form.cleaned_data['splits'],
                 total=form.cleaned_data['amount'])
             models.Operation.objects.create(
                 account=form.cleaned_data['account'],
                 transaction=form.cleaned_data['transaction'],
                 date=date + relativedelta(months=position),
                 amount=amount,
                 description=description,
             )
     return FormView.form_valid(self, form)
开发者ID:benoitbryon,项目名称:cashmere,代码行数:32,代码来源:views.py

示例3: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     # Create signature instance in local DB.
     SignatureType = django_anysign.get_signature_type_model()
     Signature = django_anysign.get_signature_model()
     Signer = django_anysign.get_signer_model()
     signature_type, created = SignatureType.objects.get_or_create(
         signature_backend_code='dummysign')
     signature = Signature.objects.create(signature_type=signature_type)
     Signer.objects.create(signature=signature)
     logger.debug(
         '[django_anysign_demo] Signature ID={id} created in local DB'
         .format(id=signature.id))
     # Register signature in backend's DB.
     signature.signature_backend.create_signature(signature)
     # Remember the signature object for later use (:meth:`get_success_url`)
     self.signature = signature
     # Handle the form as always.
     return FormView.form_valid(self, form)
开发者ID:novafloss,项目名称:django-anysign,代码行数:20,代码来源:views.py

示例4: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     form.save()
     messages.info(self.request, "Your information has been updated")
     return FormView.form_valid(self, form)
开发者ID:danielquinn,项目名称:spirithunter,代码行数:6,代码来源:views.py

示例5: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     self._profile = form.register_tenant()
     return FormView.form_valid(self, form)
开发者ID:pyarun,项目名称:djsaas,代码行数:5,代码来源:views.py

示例6: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     form.add_vote()
     return FormView.form_valid(self, form)
开发者ID:delgermurun,项目名称:tdd-django-tutorial.com,代码行数:5,代码来源:views.py

示例7: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     login(self.request, form.user)
     response = FormView.form_valid(self, form)
     response.set_cookie("alice", form.user.token)
     return response
开发者ID:adammalinowski,项目名称:export-wins-ui,代码行数:7,代码来源:views.py

示例8: form_valid

# 需要导入模块: from django.views.generic import FormView [as 别名]
# 或者: from django.views.generic.FormView import form_valid [as 别名]
 def form_valid(self, form):
     form.save()
     return FormView.form_valid(self, form)
开发者ID:pavelm2007,项目名称:mongo_test,代码行数:5,代码来源:views.py


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