django-crispy-forms

crspy-forms layout not work for django inline formset

女生的网名这么多〃 提交于 2019-12-21 06:26:18
问题 This is my forms and inlineformset class EventForm(ModelForm): def __init__(self, *args, **kwargs): super(EventForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_tag = False self.helper.layout = Layout( Field('name'), Field('description'), Field('tags'), ) self.helper.layout.append(Submit('save', 'Save')) class Meta: model = Event fields = ('name','description','tags', ) class GalleryForm(ModelForm): def __init__(self, *args, **kwargs): super(GalleryForm, self).

crspy-forms layout not work for django inline formset

故事扮演 提交于 2019-12-21 06:26:03
问题 This is my forms and inlineformset class EventForm(ModelForm): def __init__(self, *args, **kwargs): super(EventForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_tag = False self.helper.layout = Layout( Field('name'), Field('description'), Field('tags'), ) self.helper.layout.append(Submit('save', 'Save')) class Meta: model = Event fields = ('name','description','tags', ) class GalleryForm(ModelForm): def __init__(self, *args, **kwargs): super(GalleryForm, self).

Using Django model forms + form wizard + Crispy - Does not proceed to second step

。_饼干妹妹 提交于 2019-12-21 02:51:26
问题 I am fairly new to forms in django. My issue is I have a few very large models that I have to break up into a series of smaller forms for the users to fill out. So I've been playing around with crispy forms and yesterday after watching Mike Hibberts tutorial ( Python Django tutorial 19 - Using the Form Wizard ) on youtube I wanted to see if I could make this work with a crispy form. Everything seems to render ok to me, however when I press submit the form seems to be validated but does not

Django crispy-forms, BaseGenericInlineFormSet & allow_delete

*爱你&永不变心* 提交于 2019-12-19 02:05:21
问题 I came across a question while working with django-crispy-forms for which I'm unable to get an answer. I have a rather complex form layout, everything works extremly nice with cripy-forms so far. One part of the form uses a generic inline formset. This is working as well, but my problem is, that i cannot figure out how to access the delete-checkbox (when having can_delete=True ) The corresponding code looks something like: class BaseReleaseReleationFormSet(BaseGenericInlineFormSet): def _

django crispy forms: Nesting a formset within a form

人盡茶涼 提交于 2019-12-17 22:51:00
问题 I have a django Formset that I'd like to layout in the middle of another form. I'm using django-crispy-forms to set the layout in the parent form's __init__ : from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit, Layout, Field, Div def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.layout = Layout( Div( Div(Field('foo'), css_class='span3'), Div(Field('bar'), css_class='span4'), css_class='row' ), Field('baz', css_class='span1'), ... ) self

Conditionally display a Fieldset with Crispy Forms

ε祈祈猫儿з 提交于 2019-12-13 07:26:13
问题 I want to do something simple while using Crispy Forms; I want show a Fieldset only if the user belongs to the staff group. This is easily solved in a standard templates like this: {% if user.is_staff %} show extra stuff {% endif %} Maybe I missed something in the manual, but I don't see how I can just inject a template tag like "{% if user.is_staff %}" into the crispy form Layout. It would be ideal for my use case if I could something like the following where I use a fictitious 'Djangotag'

Check if a form exists or is rendered in Template. Django

让人想犯罪 __ 提交于 2019-12-13 02:49:36
问题 I have a situation where I display a Form sometimes and sometimes I don't display it. Actually, there are multiple forms using the same Submit button. What do I do to take care of the situation when a particular form is not shown in the template. The template code {% extends BASE_TEMPLATE %} {% load crispy_forms_tags %} {% block title %}<h2>New Thread</h2>{% endblock %} {% block content %} <div class="col-md-6"> <form method="post" accept-charset="utf-8">{% csrf_token %} {{ threadForm|crispy

Use field label as placeholder in django-crispy-forms

戏子无情 提交于 2019-12-12 10:42:17
问题 I'm thinking about the DRY way to use field labels for placeholder attribute of my <input> HTML elements. I'm using django-crispy-forms . Right now I have: class FilterForm(Form): query = CharField(max_length=50, label='', required=False) def __init__(self, data=None, files=None, **kwargs): self.helper = FormHelper() self.helper.layout = Layout( Field('query', placeholder='Search ...'), ) super(FilterForm, self).__init__(data, files, **kwargs) I'd prefer, however, not to have to set label and

Django login from in modal window

社会主义新天地 提交于 2019-12-12 08:13:12
问题 I have a login form and I want to put in modal window in header. Urls.py url(r'^account/login/$', appuser_views.LoginView.as_view(template_name = 'account/login/index.html', form_class = appuser_forms.LoginForm, target_url = LOGIN_TARGET_URL)), views.py class LoginView(ResendEmailToUsersMixin, AjaxFormView): def process_form(self, request, form): data = form.cleaned_data a = AppUserCredential.objects.select_related('appuser').filter( data1 = data['email_address'], credential_type =

django crispy forms accordion issue

大城市里の小女人 提交于 2019-12-11 23:04:51
问题 I have simple Accordion below: I want to setup active=True or active=False conditionally basing on value which is on reason_yes and reason_no fileds: def __init__(self, *args, **kwargs): super(MyUpdateForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder( Tab( 'Tab1', Accordion( AccordionGroup( Field('reason_yes'), active=False ), AccordionGroup( Field('reason_no'), active=True ) ) ), Tab( 'Tab2', Field('other fileds') ) ), FormActions(