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


Python forms.HiddenInput方法代码示例

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


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

示例1: new_student

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def new_student(request, userid):
    person = get_object_or_404(Person, find_userid_or_emplid(userid))
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    student = get_object_or_404(Person, find_userid_or_emplid(userid))
    initial = {'person': student.emplid, 'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80 }
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices, program_choices = \
        _appointment_defaults(request.units, emplid=student.emplid)
    gss = GradStudent.objects.filter(person=student)
    if gss:
        gradstudent = gss[0]
        initial['sin'] = gradstudent.person.sin()
    
    raform = RAForm(initial=initial)
    raform.fields['person'] = forms.CharField(widget=forms.HiddenInput())
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['hiring_faculty'].choices = hiring_faculty_choices
    raform.fields['unit'].choices = unit_choices
    raform.fields['project'].choices = project_choices
    raform.fields['account'].choices = account_choices
    raform.fields['program'].choices = program_choices
    return render(request, 'ra/new.html', { 'raform': raform, 'person': person })

#Edit RA Appointment 
开发者ID:sfu-fas,项目名称:coursys,代码行数:26,代码来源:views.py

示例2: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
                 initial=None, error_class=ErrorList, label_suffix=':',
                 empty_permitted=False, instance=None,
                 offering=None, userid=None, enforced_prep_min=0):
        super(TUGForm, self).__init__(data, files, auto_id, prefix, initial,
                 error_class, label_suffix, empty_permitted, instance)
        # see old revisions (git id 1d1d2f9) for a dropdown
        if userid is not None and offering is not None:
            member = Member.objects.exclude(role='DROP').get(person__userid=userid, offering=offering)
        elif instance is not None:
            member = instance.member
        else:
            assert False

        self.enforced_prep_min = enforced_prep_min

        self.initial['member'] = member
        self.fields['member'].widget = forms.widgets.HiddenInput()
        
        self.subforms = self.__construct_subforms(data, initial, instance) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:22,代码来源:forms.py

示例3: render

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, extra_context=None, **kwargs):
        super(ShowField, self).render(form, form_style, context, template_pack, extra_context, **kwargs)
        if extra_context is None:
            extra_context = {}
        if hasattr(self, 'wrapper_class'):
            extra_context['wrapper_class'] = self.wrapper_class

        if self.attrs:
            if 'detail-class' in self.attrs:
                extra_context['input_class'] = self.attrs['detail-class']
            elif 'class' in self.attrs:
                extra_context['input_class'] = self.attrs['class']

        html = ''
        for field, result in self.results:
            extra_context['result'] = result
            if field in form.fields:
                if form.fields[field].widget != forms.HiddenInput:
                    extra_context['field'] = form[field]
                    html += loader.render_to_string(self.template, extra_context)
            else:
                extra_context['field'] = field
                html += loader.render_to_string(self.template, extra_context)
        return html 
开发者ID:stormsha,项目名称:StormOnline,代码行数:26,代码来源:detail.py

示例4: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        if settings.NETBOX_API:
            self.fields["netbox_device_id"] = forms.ChoiceField(
                label="NetBox Device",
                choices=[(0, "--------")]
                + [
                    (device.id, device.display_name)
                    for device in NetBox().get_devices()
                ],
                widget=StaticSelect,
            )
            self.fields["netbox_device_id"].widget.attrs["class"] = " ".join(
                [
                    self.fields["netbox_device_id"].widget.attrs.get("class", ""),
                    "form-control",
                ]
            ).strip()
        else:
            self.fields["netbox_device_id"].widget = forms.HiddenInput() 
开发者ID:respawner,项目名称:peering-manager,代码行数:23,代码来源:forms.py

示例5: render_layout

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def render_layout(self, form, context, template_pack=TEMPLATE_PACK):
        """
        Copy any field label to the ``placeholder`` attribute.
        Note, this method is called when :attr:`layout` is defined.
        """
        # Writing the label values into the field placeholders.
        # This is done at rendering time, so the Form.__init__() could update any labels before.
        # Django 1.11 no longer lets EmailInput or URLInput inherit from TextInput,
        # so checking for `Input` instead while excluding `HiddenInput`.
        for field in form.fields.values():
            if field.label and \
                    isinstance(field.widget, (Input, forms.Textarea)) and \
                    not isinstance(field.widget, forms.HiddenInput):
                field.widget.attrs['placeholder'] = u"{0}:".format(field.label)

        return super(CompactLabelsCommentFormHelper, self).render_layout(form, context, template_pack=template_pack) 
开发者ID:82Flex,项目名称:DCRM,代码行数:18,代码来源:helper.py

示例6: set_choices

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def set_choices(self, family):
        # There's probably a better way of doing this
        board_choices = [(brd.id, brd.name) for brd in Board.objects.filter(family=family)]

        self.fields['board_type'].choices = board_choices


# class GuidedDeviceFlashForm(forms.Form):
#     DEVICE_FAMILY_CHOICES = GuidedDeviceSelectForm.DEVICE_FAMILY_CHOICES
#
#     device_family = forms.ChoiceField(label="Device Family",
#                                       widget=forms.Select(attrs={'class': 'form-control',
#                                                                  'data-toggle': 'select'}),
#                                       choices=DEVICE_FAMILY_CHOICES, required=True)
#     should_flash_device = forms.BooleanField(widget=forms.HiddenInput, required=False, initial=False)
#
# 
开发者ID:thorrak,项目名称:fermentrack,代码行数:19,代码来源:forms.py

示例7: get_form

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def get_form(self):
        form = super().get_form()
        form.fields['facility'].widget = forms.HiddenInput()
        form.fields['observation_id'].widget = forms.HiddenInput()
        if self.request.method == 'GET':
            target_id = self.request.GET.get('target_id')
        elif self.request.method == 'POST':
            target_id = self.request.POST.get('target_id')
        cancel_url = reverse('home')
        if target_id:
            cancel_url = reverse('tom_targets:detail', kwargs={'pk': target_id})
        form.helper.layout = Layout(
            HTML('''<p>An observation record already exists in your TOM for this combination of observation ID,
                 facility, and target. Are you sure you want to create this record?</p>'''),
            'target_id',
            'facility',
            'observation_id',
            'confirm',
            FormActions(
                Submit('confirm', 'Confirm'),
                HTML(f'<a class="btn btn-outline-primary" href={cancel_url}>Cancel</a>')
            )
        )
        return form 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:26,代码来源:views.py

示例8: get_context_data

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def get_context_data(self, *args, **kwargs):
        """
        Adds the ``DataProductUploadForm`` to the context and prepopulates the hidden fields.

        :returns: context object
        :rtype: dict
        """
        context = super().get_context_data(*args, **kwargs)
        observing_strategy_form = RunStrategyForm(initial={'target': self.get_object()})
        if any(self.request.GET.get(x) for x in ['observing_strategy', 'cadence_strategy', 'cadence_frequency']):
            initial = {'target': self.object}
            initial.update(self.request.GET)
            observing_strategy_form = RunStrategyForm(
                initial=initial
            )
        observing_strategy_form.fields['target'].widget = HiddenInput()
        context['observing_strategy_form'] = observing_strategy_form
        return context 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:20,代码来源:views.py

示例9: get_form

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def get_form(self):
        """ Get form for StockItem editing.

        Limit the choices for supplier_part
        """

        form = super(AjaxUpdateView, self).get_form()

        item = self.get_object()

        # If the part cannot be purchased, hide the supplier_part field
        if not item.part.purchaseable:
            form.fields['supplier_part'].widget = HiddenInput()
        else:
            query = form.fields['supplier_part'].queryset
            query = query.filter(part=item.part.id)
            form.fields['supplier_part'].queryset = query

        if not item.part.trackable or not item.serialized:
            form.fields.pop('serial')

        return form 
开发者ID:inventree,项目名称:InvenTree,代码行数:24,代码来源:views.py

示例10: get_form

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def get_form(self):
        """ Create form for editing a BuildItem.

        - Limit the StockItem options to items that match the part
        """

        build_item = self.get_object()

        form = super(BuildItemEdit, self).get_form()

        query = StockItem.objects.all()
        
        if build_item.stock_item:
            part_id = build_item.stock_item.part.id
            query = query.filter(part=part_id)

        form.fields['stock_item'].queryset = query

        form.fields['build'].widget = HiddenInput()

        return form 
开发者ID:inventree,项目名称:InvenTree,代码行数:23,代码来源:views.py

示例11: get_master_form

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def get_master_form(self, model=None, pk=None):
        pk = int(pk) if pk is not None else pk
        if pk is not None and pk in self.djangui_forms:
            if 'master' in self.djangui_forms[pk]:
                return copy.deepcopy(self.djangui_forms[pk]['master'])
        master_form = DjanguiForm()
        params = ScriptParameter.objects.filter(script=model).order_by('pk')
        # set a reference to the object type for POST methods to use
        pk = model.pk
        script_id_field = forms.CharField(widget=forms.HiddenInput)
        master_form.fields['djangui_type'] = script_id_field
        master_form.fields['djangui_type'].initial = pk

        for param in params:
            field = self.get_field(param)
            master_form.fields[param.slug] = field
        try:
            self.djangui_forms[pk]['master'] = master_form
        except KeyError:
            self.djangui_forms[pk] = {'master': master_form}
        # create the group forms while we have the model
        if 'groups' not in self.djangui_forms[pk]:
            self.get_group_forms(model=model, pk=pk)
        return master_form 
开发者ID:Chris7,项目名称:django-djangui,代码行数:26,代码来源:factory.py

示例12: get_image_form

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def get_image_form(model):
    fields = model.admin_form_fields
    if 'collection' not in fields:
        # force addition of the 'collection' field, because leaving it out can
        # cause dubious results when multiple collections exist (e.g adding the
        # document to the root collection where the user may not have permission) -
        # and when only one collection exists, it will get hidden anyway.
        fields = list(fields) + ['collection']

    return modelform_factory(
        model,
        form=BaseImageForm,
        fields=fields,
        formfield_callback=formfield_for_dbfield,
        # set the 'file' widget to a FileInput rather than the default ClearableFileInput
        # so that when editing, we don't get the 'currently: ...' banner which is
        # a bit pointless here
        widgets={
            'tags': widgets.AdminTagWidget,
            'file': forms.FileInput(),
            'focal_point_x': forms.HiddenInput(attrs={'class': 'focal_point_x'}),
            'focal_point_y': forms.HiddenInput(attrs={'class': 'focal_point_y'}),
            'focal_point_width': forms.HiddenInput(attrs={'class': 'focal_point_width'}),
            'focal_point_height': forms.HiddenInput(attrs={'class': 'focal_point_height'}),
        }) 
开发者ID:wagtail,项目名称:wagtail,代码行数:27,代码来源:forms.py

示例13: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
        super(HiddenForm, self).__init__(*args, **kwargs)
        for field in self.fields:
            self.fields[field].widget = forms.HiddenInput() 
开发者ID:PiDelport,项目名称:django-payfast,代码行数:6,代码来源:forms.py

示例14: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def __init__(self, model, objects, *args, **kwargs):
        super(MergeObjectsForm, self).__init__(*args, **kwargs)
        self.model = model
        self.choices = []
        for objId in objects:
            choice_name = '#%d: ' % objId + str(self.model.objects.get(id=objId))
            self.choices.append((objId, choice_name))
        self.fields['root'] = forms.ChoiceField(choices=self.choices, required=True)
        self.fields['objects'] = forms.CharField(
            initial=','.join([str(i) for i in objects]), widget=forms.HiddenInput()
        ) 
开发者ID:GamesDoneQuick,项目名称:donation-tracker,代码行数:13,代码来源:forms.py

示例15: edit

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import HiddenInput [as 别名]
def edit(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False, unit__in=request.units)
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices, program_choices = \
        _appointment_defaults(request.units, emplid=appointment.person.emplid)
    if request.method == 'POST':
        data = request.POST.copy()
        if data['pay_frequency'] == 'L':
            # force legal values into the non-submitted (and don't-care) fields for lump sum pay
            data['biweekly_pay'] = 1
            data['hourly_pay'] = 1
            data['hours'] = 1
            data['pay_periods'] = 1
        
        raform = RAForm(data, instance=appointment)
        if raform.is_valid():
            userid = raform.cleaned_data['person'].userid
            appointment = raform.save(commit=False)
            appointment.set_use_hourly(raform.cleaned_data['use_hourly'])
            appointment.save()
            l = LogEntry(userid=request.user.username,
                         description="Edited RA appointment %s." % appointment,
                         related_object=appointment)
            l.save()
            messages.success(request, 'Updated RA Appointment for ' + appointment.person.first_name + " " + appointment.person.last_name)
            return HttpResponseRedirect(reverse('ra:student_appointments', kwargs=({'userid': userid})))
    else:
        #The initial value needs to be the person's emplid in the form. Django defaults to the pk, which is not human readable.
        raform = RAForm(instance=appointment, initial={'person': appointment.person.emplid, 'use_hourly': appointment.use_hourly()})
        #As in the new method, choices are restricted to relevant options.
        raform.fields['person'] = forms.CharField(widget=forms.HiddenInput())
        raform.fields['hiring_faculty'].choices = hiring_faculty_choices
        raform.fields['scholarship'].choices = scholarship_choices
        raform.fields['unit'].choices = unit_choices
        raform.fields['project'].choices = project_choices
        raform.fields['account'].choices = account_choices
        raform.fields['program'].choices = program_choices
    return render(request, 'ra/edit.html', { 'raform': raform, 'appointment': appointment, 'person': appointment.person })


#Quick Reappoint, The difference between this and edit is that the reappointment box is automatically checked, and date information is filled out as if a new appointment is being created.
#Since all reappointments will be new appointments, no post method is present, rather the new appointment template is rendered with the existing data which will call the new method above when posting. 
开发者ID:sfu-fas,项目名称:coursys,代码行数:43,代码来源:views.py


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