本文整理汇总了Python中django.forms.widgets.HiddenInput方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.HiddenInput方法的具体用法?Python widgets.HiddenInput怎么用?Python widgets.HiddenInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.widgets
的用法示例。
在下文中一共展示了widgets.HiddenInput方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
super(BootsrapForm, self).__init__(*args, **kwargs)
for field in self.fields.values():
# Only tweak the field if it will be displayed
if not isinstance(field.widget, widgets.HiddenInput):
attrs = {}
if (
isinstance(field.widget, (widgets.Input, widgets.Select, widgets.Textarea)) and
not isinstance(field.widget, (widgets.CheckboxInput,))
):
attrs['class'] = "form-control"
if isinstance(field.widget, (widgets.Input, widgets.Textarea)) and field.label:
attrs["placeholder"] = field.label
if field.required:
attrs["required"] = "required"
field.widget.attrs.update(attrs)
示例2: test_edit_attachments_cannot_set_mount_point
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def test_edit_attachments_cannot_set_mount_point(self):
volume = self.cinder_volumes.first()
servers = [s for s in self.servers.list()
if s.tenant_id == self.request.user.tenant_id]
cinder.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume)
api.nova.server_list(IsA(http.HttpRequest)).AndReturn([servers, False])
self.mox.ReplayAll()
url = reverse('horizon:project:volumes:volumes:attach',
args=[volume.id])
res = self.client.get(url)
# Assert the device field is hidden.
form = res.context['form']
self.assertTrue(isinstance(form.fields['device'].widget,
widgets.HiddenInput))
示例3: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
self.base_fields[TOTAL_FORM_COUNT] = IntegerField(widget=HiddenInput)
self.base_fields[INITIAL_FORM_COUNT] = IntegerField(widget=HiddenInput)
# MIN_NUM_FORM_COUNT and MAX_NUM_FORM_COUNT are output with the rest of
# the management form, but only for the convenience of client-side
# code. The POST value of them returned from the client is not checked.
self.base_fields[MIN_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
self.base_fields[MAX_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
super(ManagementForm, self).__init__(*args, **kwargs)
示例4: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
self.base_fields[TOTAL_FORM_COUNT] = IntegerField(widget=HiddenInput)
self.base_fields[INITIAL_FORM_COUNT] = IntegerField(widget=HiddenInput)
# MIN_NUM_FORM_COUNT and MAX_NUM_FORM_COUNT are output with the rest of
# the management form, but only for the convenience of client-side
# code. The POST value of them returned from the client is not checked.
self.base_fields[MIN_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
self.base_fields[MAX_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
super().__init__(*args, **kwargs)
示例5: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
self.base_fields[TOTAL_FORM_COUNT] = IntegerField(widget=HiddenInput)
self.base_fields[INITIAL_FORM_COUNT] = IntegerField(widget=HiddenInput)
self.base_fields[MAX_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
super(ManagementForm, self).__init__(*args, **kwargs)
示例6: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
super(MeterModelCreateForm, self).__init__(*args, **kwargs)
meter_id = self.initial.get('meter_id')
self.meter_hidden = False
if meter_id:
try:
Meter.objects.get(meter_id=meter_id)
self.fields['meter_id'].widget = HiddenInput()
self.meter_hidden = True
except Meter.DoesNotExist:
logger.error('CalcMeterSavingsForm: Meter not found with id = %s', meter_id)
self.initial.pop('meter_id')
示例7: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, request=None, allow_clicked_position=False, **kwargs):
self.request = request
super().__init__(*args, **kwargs)
GraphNode = self.request.changeset.wrap_model('GraphNode')
graph_node_qs = GraphNode.objects.all()
self.fields['active_node'] = ModelChoiceField(graph_node_qs, widget=HiddenInput(), required=False)
self.fields['clicked_node'] = ModelChoiceField(graph_node_qs, widget=HiddenInput(), required=False)
if allow_clicked_position:
self.fields['clicked_position'] = CharField(widget=HiddenInput(), required=False)
Space = self.request.changeset.wrap_model('Space')
space_qs = Space.objects.all()
self.fields['goto_space'] = ModelChoiceField(space_qs, widget=HiddenInput(), required=False)
示例8: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, attrs=None):
widgets = (HiddenInput(attrs=attrs), HiddenInput(attrs=attrs))
super(VATINWidget, self).__init__(widgets, attrs)
示例9: __init__
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
self.group = kwargs.pop('group')
read_only = kwargs.pop('read_only') if 'read_only' in kwargs else False
super().__init__(*args, **kwargs)
self.fields['collection'].queryset = self.fields['collection'].queryset.filter(
owner_id=self.user.id
)
if read_only:
self.fields['collection'].widget = HiddenInput()
self.fields['collection'].widget.attrs['readonly'] = read_only
示例10: test_launch_form_instance_device_name_hidden
# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import HiddenInput [as 别名]
def test_launch_form_instance_device_name_hidden(self):
self._test_launch_form_instance_show_device_name(
u'', widgets.HiddenInput, {
'name': 'device_name', 'value': '',
'attrs': {'id': 'id_device_name'}}
)