FAQ Database Discussion Community


Django Crispy forms doesn't save when custom layout is added

python,django,django-crispy-forms
from views.py: class EmployeeUpdateView(LoginRequiredMixin, UpdateView): model = Employee template_name = "employee_update.html" form_class = EmployeeUpdateForm From forms.py: class EmployeeForm(forms.ModelForm): departments = DepartmentChoiceField() def __init__(self, *args, **kwargs): super(EmployeeForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = "form-vertical" self.helper.form_tag = False self.helper.layout = Layout( Div(Field('first_name'), css_class="row col-md-5 emp-firstname"),...

Django - ModelForm: Add a field not belonging to the model

python,django,django-forms,django-crispy-forms
Note: Using django-crispy-forms library for my form. If you have a solution to my problem that involves not using the cripsy_forms library, I accept it all the same. Not trying to be picky just need a solution / work around. Thanks In my form's Meta class I set the model,...

Django render a form field with css using crispy forms

python,django,django-forms,django-templates,django-crispy-forms
I have a form I want to render with crispy form, FORM class MyForm(forms.ModelForm): class Meta: model = MyModel excludes = ('user', 'created') def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_show_labels = False ## I only need the input field self.helper.layout = layout.Layout( layout.Field('name', css_class="form-control"), layout.Field('objective', css_class="form-control"), ## ADD CLASS...

Django Crispy Forms and Bootstrap Awesome Checkbox

django,checkbox,django-crispy-forms
Is there any way to get Django Crispy-forms to emit the layout for a checkbox in a slightly different way to accomodate Bootstrap Awesome Checkbox (https://github.com/flatlogic/awesome-bootstrap-checkbox)? NOTE: this can't be done via a CSS change. The INPUT tag is no longer a child of the LABEL tag with the awesome-checkbox...it's...

Mixing Django crispy forms with FormView

python,django,formview,django-crispy-forms
I wanted to make a Django contact form on website and I found Django crispy forms very useful for that, but it turned out that I can't mix it with Django FormView just like this. Crispy forms have done awesome job in front-end layout, but I can't grab any information...

Django CrispyForms - Render every form of a formset in separate bootstrap tabs

django,twitter-bootstrap-3,django-crispy-forms
I would like to render each form of a formset in a different bootstrap3 tabs using django-crispyForms, but it seems to not be simple because crispyForms does not handle formset completely yet. my form: class BlogMessageForm(forms.ModelForm): class Meta: model = BlogMessage fields = ['field1', 'field2', ] class BlogMessageFormsetHelper(FormHelper): def __init__(self,...

Django - Combining a datatable view and form view

django,django-crispy-forms
I am trying to put a table from datatables and a crispy form into one view so that I can display it on a single page in django. I am completely stuck on how to combine them as i'm still a newbie. Any help is greatly appreciated!! Views.py ------------- Datatable...

Error composing layouts with django-crispy

python,django,layout,django-crispy-forms
I want to build several forms in Django with django-crispy using a common layout. I read the crispy documentation about composing layouts, but I cannot made it all by myself, because I get the message error: append() takes exactly one argument (2 given). See my code below: # a class...

Django ClearableFileInput - how to detect whether to delete the file

django,django-forms,django-crispy-forms
I'm using Django Crispy Forms for my form with an option to upload an image (ImageField in my Model) The forms renders as I'd expect, with the checkbox to clear an existing file. However when processing the form submission the 'image-clear' checkbox always gives me a 'None' value. image_clear =...

Django - Disable form select field validation

python,django,forms,django-crispy-forms
I have a form that lets me first select a product type and then select the product. As i have 1000+ products i use the following to filter the product list to improve performance. I have the following inlineform in my views.py OrderLineFormSet = inlineformset_factory(OrderHeader, OrderLine, OrderLineForm, extra = 1)...