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


Python Form.fields[key]方法代码示例

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


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

示例1: get_payment_process_response

# 需要导入模块: from django.forms import Form [as 别名]
# 或者: from django.forms.Form import fields[key] [as 别名]
 def get_payment_process_response(self, service, order, urls):
     address = order.billing_address
     payment = Payment(
         order_number=order.identifier,
         reference_number=order.reference_number[:20],
         amount=str(int(order.taxful_total_price * 100)),
         delivery_date=(order.order_date.date() + datetime.timedelta(1)).strftime("%Y%m%d"),
         return_url=urls.return_url,
         delayed_url=urls.return_url,
         cancel_url=urls.cancel_url,
         message=force_text(order),
         contact=Contact(
             first_name=flatten_unicode(address.first_name),
             last_name=flatten_unicode(address.last_name),
             email=flatten_unicode(address.email),
             phone=flatten_unicode(address.phone),
             address=flatten_unicode(address.street),
             postcode=address.postal_code,
             postoffice=flatten_unicode(address.city),
             country=address.country.alpha3
         )
     )
     form = Form()
     for key, value in self._get_checkout_object(service).get_offsite_button_data(payment).items():
         form.fields[key] = CharField(initial=value, widget=HiddenInput)
     html = TEMPLATE % {
         "form": form,
         "continue_text": _("Continue to Checkout.fi"),
     }
     return HttpResponse(html)
开发者ID:shuup,项目名称:shuup-checkoutfi,代码行数:32,代码来源:models.py

示例2: _create_search_form

# 需要导入模块: from django.forms import Form [as 别名]
# 或者: from django.forms.Form import fields[key] [as 别名]
    def _create_search_form(self, request):
        form = Form(request.GET)
        form.fields[self.searchable_key] = CharField(
            label = self.searchable_label,
            required = False
        )
        form.fields[self.searchable_key].widget.attrs.update(
           {
               'class': 'searchable-form',
               'placeholder': '...',
           }
        )

        # Add hidden input fields to keep current query sting
        for key, value in request.GET.items():
            if key != self.searchable_key:
                form.fields[key] = CharField(widget=HiddenInput())

        return form
开发者ID:nrocco,项目名称:rocco-django,代码行数:21,代码来源:mixins.py


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