本文整理匯總了Python中crispy_forms.layout.Layout方法的典型用法代碼示例。如果您正苦於以下問題:Python layout.Layout方法的具體用法?Python layout.Layout怎麽用?Python layout.Layout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類crispy_forms.layout
的用法示例。
在下文中一共展示了layout.Layout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
self._email_token = kwargs.pop('email_token', None)
self._verification_code = self._email_token.verification_code
super(EmailVerificationForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id_form_email_verification'
self.helper.form_action = reverse_lazy('accounts_email_verification', args=(self._email_token.id,))
self.helper.layout = Layout(
Div(
'code',
),
HTML('''<hr class="full">'''),
Div(
Div(
HTML('''<a href="{% url 'accounts_register' %}">
{{ _('Cancel and sign up again') }}</a> '''),
Submit('submit', _('Verify Email address'), css_class='btn-success btn-lg'),
css_class='pull-right'
)
)
)
示例2: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super(KeywordCreateForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id_form_keywords_create'
self.helper.layout = Layout(
Div(
Div(
'term',
css_class='col-sm-6 col-sm-offset-3'
),
css_class='row'
),
HTML('''<hr class="full">'''),
Div(
Div(
HTML('''<a href="{% url 'keywords_manage' %}">{{ _('Cancel') }}</a> '''),
Submit('submit', _('Save'), css_class='btn-success btn-lg'),
css_class='pull-right'
),
css_class='row',
)
)
示例3: helper
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def helper(self):
# As extra service, auto-adjust the layout based on the project settings.
# This allows defining the top-row, and still get either 2 or 3 columns
compact_fields = [name for name in self.fields.keys() if name in self.top_row_fields]
other_fields = [name for name in self.fields.keys() if name not in self.top_row_fields]
col_size = int(self.top_row_columns / len(compact_fields))
col_class = self.top_column_class.format(size=col_size)
compact_row = Row(*[Column(name, css_class=col_class) for name in compact_fields])
# The fields are already ordered by the AbstractCommentForm.__init__ method.
# See where the compact row should be.
pos = list(self.fields.keys()).index(compact_fields[0])
new_fields = other_fields
new_fields.insert(pos, compact_row)
helper = CompactLabelsCommentFormHelper()
helper.layout = Layout(*new_fields)
helper.add_input(SubmitButton())
helper.add_input(PreviewButton())
return helper
示例4: get_form
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [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
示例5: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = reverse('tom_observations:add-existing')
self.helper.layout = Layout(
'target_id',
'confirm',
Row(
Column(
'facility'
),
Column(
'observation_id'
),
Column(
ButtonHolder(
Submit('submit', 'Add Existing Observation')
)
)
)
)
示例6: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field_name in ['groups', 'target_id']:
self.fields.pop(field_name, None)
for field in self.fields:
if field != 'strategy_name':
self.fields[field].required = False
self.helper.layout = Layout(
self.common_layout,
Div(
Div(
'proposal', 'ipp_value', 'filter', 'instrument_type',
css_class='col'
),
Div(
'exposure_count', 'exposure_time', 'max_airmass',
css_class='col'
),
css_class='form-row',
)
)
示例7: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user")
kwargs.update(
{
"initial": {
"contact_name": self.user.get_full_name,
"contact_email": self.user.email,
}
}
)
super(SponsorApplicationForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.field_class = "col-sm-10 col-lg-10"
self.helper.form_tag = False
self.helper.label_class = "col-sm-2 col-lg-2"
self.helper.layout = Layout(
"name",
"external_url",
"contact_name",
"contact_email",
"level",
)
示例8: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super(ActionItemForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.layout = Layout(
Row(
Column(css_class='form-group col-md-3 col-xs-4'),
Column('due_date', css_class='form-group col-md-3 col-xs-4'),
Column('instruction', css_class='form-group col-md-3 col-xs-4'),
css_class='form-row'
),
Row(
Column(css_class='form-group col-md-3 col-xs-4'),
Column('comments', css_class='form-group col-md-6 col-xs-6')
),
CustomCheckbox('priority'),
Row(
Column(Submit('submit', 'Submit'),
css_class='formgroup col-md-offset-3 col-xs-offset-4')
)
)
self.fields['instruction'].queryset = models.ActionInstruction.objects.filter(
active=True)
示例9: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super(DemographicsForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.layout = Layout(
Fieldset('Medical',
'has_insurance',
'ER_visit_last_year',
'last_date_physician_visit',
'chronic_condition'),
Fieldset('Social',
'lives_alone',
'dependents',
'resource_access',
'transportation'),
Fieldset('Employment',
'currently_employed',
'education_level',
'work_status',
'annual_income')
)
self.helper.add_input(Submit('submit', 'Submit'))
示例10: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super(MessageRecipientForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-md-3'
self.helper.field_class = 'col-md-8'
self.fields['recipient_approved_public'].label = "I agree to publish this message and display it publicly in the Happiness Archive."
self.fields['recipient_approved_public_named'].label = "... and I agree to display our names publicly too."
self.fields['recipient_approved_public_named'].help_text = "Note: We only publish information if both the sender and the recipients agree."
self.helper.layout = Layout(
Fieldset("Privacy and permissions", 'recipient_approved_public', 'recipient_approved_public_named'),
HTML("<br>"),
Submit('submit', 'Save privacy choices', css_class='btn-lg centered'),
)
示例11: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super(PageMassChangeForm, self).__init__(*args, **kwargs)
color_scheme_fields = self.init_color_scheme_switch(
color_scheme=kwargs['initial'].get('color_scheme', None),
field_kwargs={'widget': Select2Widget})
self.helper.layout = Layout(
TabHolder(
Tab(_('Options'),
'depth',
'page_id',
'from_root',
'site',
'language',
),
Tab(_('Styles'),
'layout',
Fieldset(
'Themes', 'theme', *color_scheme_fields),
),
),
)
示例12: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Row(
Column('email', css_class='form-group col-md-6 mb-0'),
Column('password', css_class='form-group col-md-6 mb-0'),
css_class='form-row'
),
'address_1',
'address_2',
Row(
Column('city', css_class='form-group col-md-6 mb-0'),
Column('state', css_class='form-group col-md-4 mb-0'),
Column('zip_code', css_class='form-group col-md-2 mb-0'),
css_class='form-row'
),
'check_me_out',
Submit('submit', 'Sign in')
)
示例13: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
self.collection = kwargs.pop("collection", None)
super(BaseBulkSeedForm, self).__init__(*args, **kwargs)
self.fields['history_note'].help_text = HISTORY_NOTE_HELP_ADD
cancel_url = reverse('collection_detail', args=[self.collection])
self.helper = FormHelper(self)
self.helper.layout = Layout(
Fieldset(
'',
'seeds_type',
'tokens',
'history_note',
css_class='crispy-form-custom'
),
FormActions(
Submit('submit', 'Save'),
Button('cancel', 'Cancel',
onclick="window.location.href='{0}'".format(cancel_url))
)
)
示例14: form
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def form(self):
form = super(FilterSet, self).form
if compat.is_crispy():
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit
layout_components = list(form.fields.keys()) + [
Submit('', _('Submit'), css_class='btn-default'),
]
helper = FormHelper()
helper.form_method = 'GET'
helper.template_pack = 'bootstrap3'
helper.layout = Layout(*layout_components)
form.helper = helper
return form
示例15: __init__
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Layout [as 別名]
def __init__(self, *args, **kwargs):
super(SuggestionForm, self).__init__(*args, **kwargs)
# Translators: This labels a textfield where users can enter the name of the potential partner they'll suggest
self.fields["suggested_company_name"].label = _("Name of the potential partner")
# Translators: This labels a textfield where users can enter the description of the potential partner they'll suggest
self.fields["description"].label = _("Description")
# Translators: This labels a textfield where users can enter the website URL of the potential partner they'll suggest
self.fields["company_url"].label = _("Website")
# @TODO: This sort of gets repeated in PartnerSuggestionView.
# We could probably be factored out to a common place for DRYness.
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.form_class = "form-horizontal"
self.helper.label_class = "col-lg-3"
self.helper.field_class = "col-lg-7"
self.helper.layout = Layout(
"suggested_company_name",
"description",
"company_url",
"next",
# Translators: This labels a button which users click to submit their suggestion.
Submit("submit", _("Submit"), css_class="center-block"),
)