django-crispy-forms

Django crispy-forms, BaseGenericInlineFormSet & allow_delete

∥☆過路亽.° 提交于 2019-11-30 19:54:00
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 __init__(self, *args, **kwargs): self.instance = kwargs['instance'] super(BaseReleaseReleationFormSet, self)

Django form with fields from two different models

↘锁芯ラ 提交于 2019-11-30 07:11:08
I need to display one form, with multiple fields from 2 different models. Form will contain only part of fields from models, and layout will be made using the crispy forms. My models: class Company(BaseModel): title = models.CharField(_('Company'), max_length=128) domain = models.CharField(_('Domain'), max_length=128) class Account(BaseModel): company = models.ForeignKey(Company) user = models.OneToOneField(User) role = models.CharField(_('Role'), choices=ROLES, default='member', max_length=32) Fields which I want to show in form: company title, user first name, user last name, user email Is

BooleanField checkbox not render correctly with crispy_forms using bootstrap

北城以北 提交于 2019-11-29 10:59:53
I am using crispy_forms and FormHelper. I have a model field declared as: active = models.BooleanField(default=True) And in my ModelForm, I have tried both the following in my Layout: self.helper.layout = Layout( ... InlineCheckboxes('active'), Field('active'), ... which both not providing the desired result: Please see image link While using InlineCheckboxes, I do not see the checkbox and using only Field, it's not formatted correctly. Please help Here is the link to the "Bootstrap Layout objects" section of Crispy Forms docs. InlineCheckboxes : It renders a Django forms.MultipleChoiceField

Django form with fields from two different models

两盒软妹~` 提交于 2019-11-29 09:05:34
问题 I need to display one form, with multiple fields from 2 different models. Form will contain only part of fields from models, and layout will be made using the crispy forms. My models: class Company(BaseModel): title = models.CharField(_('Company'), max_length=128) domain = models.CharField(_('Domain'), max_length=128) class Account(BaseModel): company = models.ForeignKey(Company) user = models.OneToOneField(User) role = models.CharField(_('Role'), choices=ROLES, default='member', max_length

Displaying multiple Rows and Columns in django-crispy-forms

依然范特西╮ 提交于 2019-11-29 02:47:33
问题 I'm using django-crispy-forms with Twitter Bootstrap , and I'm having some issues with customizing my forms into multiple rows and columns. One example problem is that nothing happens when I try to split the form into two columns: class SomeForm(ModelForm): helper = FormHelper() helper.layout = Layout( Column('field1', 'field3'), Column('field2', 'field4'), ) ) class Meta: model = Model Looking at the html output, I see that there is the <div class="formColumn"> , but the form is displayed in

django crispy forms with jinja2

你。 提交于 2019-11-28 21:58:13
I want to use Jinja2 and Django crispy forms together, but when I load crispy_forms_tags in my template and trying to render form with this template tag, I get an error: Encountered unknown tag 'crispy'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block'. My template code: {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} <div class="panel-heading"><h3>Registration</h3></div> {% crispy form %} {% endblock %} How can I use this apps together? Better solution: templatetags.py from crispy_forms.utils import render

use Crispy form with ModelForm

[亡魂溺海] 提交于 2019-11-28 18:22:06
I've been running into crispy form , and it seems to do exactly what I want: render forms with bootstrap layout. Now, the example talk about using forms.Form . This is ok, I can create mine by writing the code like this: class TemplateCreateForm(forms.Form): title = forms.CharField(label=(u'Task name')) description = forms.CharField(label=(u'Task description')) url_start = forms.CharField(label=(u'Start page url')) url_end = forms.CharField(label=(u'Final page url')) def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_method = 'post' self.helper.add_input(Submit(

BooleanField checkbox not render correctly with crispy_forms using bootstrap

时光总嘲笑我的痴心妄想 提交于 2019-11-28 04:26:06
问题 I am using crispy_forms and FormHelper. I have a model field declared as: active = models.BooleanField(default=True) And in my ModelForm, I have tried both the following in my Layout: self.helper.layout = Layout( ... InlineCheckboxes('active'), Field('active'), ... which both not providing the desired result: Please see image link While using InlineCheckboxes, I do not see the checkbox and using only Field, it's not formatted correctly. Please help 回答1: Here is the link to the "Bootstrap

django crispy forms with jinja2

♀尐吖头ヾ 提交于 2019-11-27 14:08:15
问题 I want to use Jinja2 and Django crispy forms together, but when I load crispy_forms_tags in my template and trying to render form with this template tag, I get an error: Encountered unknown tag 'crispy'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block'. My template code: {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} <div class="panel-heading"><h3>Registration</h3></div> {% crispy form %} {% endblock %}