當前位置: 首頁>>代碼示例>>Python>>正文


Python generic.FormView類代碼示例

本文整理匯總了Python中django.views.generic.FormView的典型用法代碼示例。如果您正苦於以下問題:Python FormView類的具體用法?Python FormView怎麽用?Python FormView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FormView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_form_kwargs

    def get_form_kwargs(self):
        """ Setup additional kwargs for the form """

        kwargs = FormView.get_form_kwargs(self)
        kwargs["request"] = self.request
        kwargs["initial"]["win"] = self.kwargs["win_id"]
        return kwargs
開發者ID:UKTradeInvestment,項目名稱:export-wins-ui,代碼行數:7,代碼來源:views.py

示例2: get_context_data

 def get_context_data(self, **kwargs):
     context = super(BaseAccessListLab, self).get_context_data(
         **kwargs)
     context.update(FormView.get_context_data(self, **kwargs))
     context['role'] = self.role
     context['user_create_form'] = self.user_create_form()
     return context
開發者ID:solvo,項目名稱:organilab,代碼行數:7,代碼來源:access.py

示例3: form_valid

 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,代碼行數:30,代碼來源:views.py

示例4: form_valid

    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,代碼行數:26,代碼來源:views.py

示例5: get_context_data

    def get_context_data(self, **kwargs):
        """ Get Win data for use in the template """

        context = FormView.get_context_data(self, **kwargs)
        context.update({"win": self.win_dict})
        context['win']['date'] = date_parser(self.win_dict['date'])
        return context
開發者ID:UKTradeInvestment,項目名稱:export-wins-ui,代碼行數:7,代碼來源:views.py

示例6: get_context_data

 def get_context_data(self, **kwargs):
     ctx = FormView.get_context_data(self, **kwargs)
     basket = self.request.basket  # type: shoop.front.basket.objects.BaseBasket
     ctx["basket"] = basket
     errors = list(basket.get_validation_errors(shop=self.request.shop))
     ctx["errors"] = errors
     ctx["orderable"] = (not errors)
     return ctx
開發者ID:noyonthe1,項目名稱:shoop,代碼行數:8,代碼來源:single_page.py

示例7: get_context_data

 def get_context_data(self, **kwargs):
     ctx = FormView.get_context_data(self, **kwargs)
     basket = self.request.basket  # type: shoop.front.basket.objects.BaseBasket
     ctx["basket"] = basket
     basket.calculate_taxes()
     errors = list(basket.get_validation_errors())
     ctx["errors"] = errors
     ctx["orderable"] = not errors
     return ctx
開發者ID:cuberskulk,項目名稱:shoop,代碼行數:9,代碼來源:single_page.py

示例8: get

 def get(self, request, *args, **kwargs):
     """ a safe guard to make sure that user is already authenticated
     
     :returns: if user is authenticated return form page OR return to form user login
     using overiding @method_decorator(login_required)
               
     """
     self.args=args
     if self.request.user.is_authenticated():
          return FormView.get(self, request, *args, **kwargs)
開發者ID:drayanaindra,項目名稱:polling,代碼行數:10,代碼來源:views.py

示例9: dispatch

    def dispatch(self, request, *args, **kwargs):
        """ Override dispatch to do some checks before displaying form """

        # quick hack to show sample customer response form with known test win
        if request.path.endswith('sample/'):
            kwargs['win_id'] = os.getenv('SAMPLE_WIN', 'notconfigured')
            self.kwargs['win_id'] = kwargs['win_id']
            self.sample = True

        try:
            self.win_dict = self._get_valid_win(kwargs["win_id"], request)
        except self.SecurityException as e:
            return self._deny_access(request, message=str(e))

        return FormView.dispatch(self, request, *args, **kwargs)
開發者ID:UKTradeInvestment,項目名稱:export-wins-ui,代碼行數:15,代碼來源:views.py

示例10: form_valid

 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,代碼行數:18,代碼來源:views.py

示例11: get_context_data

 def get_context_data(self, **kwargs):
     """ pass args form get to template as context 
     
     the add_choices context is to give how many additional input choices
     to the form
     
     """
     context = FormView.get_context_data(self, **kwargs)
     
     # checking from POST request
     request_choice = self.request.POST.get('request_choice',0)
     last_choice = int (request_choice) - 2 if request_choice else 0
     
     # assign from last_choice, ignore from GET, because input from POST
     # from javascript has higher precedence than GET
     if last_choice :
         context['add_choices'] =  last_choice
     else :
         # checking from arguments (GET)
         # get previous total choices in the form, if exist
         previous = int(self.args[1])if len (self.args) == 2 else 0
         context['add_choices'] = int(self.args[0]) + previous if len(self.args) > 0 else 0
     
     return context 
開發者ID:drayanaindra,項目名稱:polling,代碼行數:24,代碼來源:views.py

示例12: get_context_data

 def get_context_data(self, **kwargs):
     context = FormView.get_context_data(self, **kwargs)
     context['page_title'] = self.page_title
     context['allow_new_registrations'] = settings.ALLOW_NEW_REGISTRATIONS
     return context
開發者ID:edkent,項目名稱:cloud-copasi,代碼行數:5,代碼來源:account_views.py

示例13: form_valid

 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,代碼行數:4,代碼來源:views.py

示例14: get_success_url

 def get_success_url(self):
     self.success_url = self.request.POST['next']
     return FormView.get_success_url(self)
開發者ID:fmareuil,項目名稱:coursera,代碼行數:3,代碼來源:views.py

示例15: patterns

from django.conf.urls import patterns, url
from django.views.generic import TemplateView, FormView
from forms import ExampleForm

urlpatterns = patterns('',
    url(r'^$', FormView.as_view(template_name='example.html', form_class=ExampleForm))
)
開發者ID:neomanic,項目名稱:django-dropzone,代碼行數:7,代碼來源:urls.py


注:本文中的django.views.generic.FormView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。