當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。