django-crispy-forms

django-crispy-forms : help_text_inline of FormHelper not working as expected

♀尐吖头ヾ 提交于 2019-12-11 12:48:14
问题 For the following model: class MyModel(models.Model): name = models.CharField(max_length=110, help_text="Some sample help text.") def __unicode__(self): return u'%s' % (self.name) And the following modelform: class MyModelForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(MyModelForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'id-myModelForm' self.helper.form_class = 'form-horizontal' self.helper.form_action = 'my_model_form_url' self

crispy-form's Helper doesn't take effect

余生颓废 提交于 2019-12-11 09:38:11
问题 It seems the FormHelper simply doesn't anything. Here's my Form: class PerguntarForm(forms.Form): title = forms.CharField(label='Título', max_length=200) categoria = forms.ModelChoiceField(queryset=Category.objects.all(), empty_label=None) orcamento = forms.FloatField(label='Preço máximo') def __init__(self, *args, **kwargs): super(PerguntarForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout.append(Submit('save', 'save')) self.helper.layout = Layout(

Crispy-Forms Include Tag Causing Many Duplicate Templates

安稳与你 提交于 2019-12-11 05:17:52
问题 I have a Django site that uses the below template to render a crispy-forms model formset. Using django-debug-toolbar , I gathered that the include tags are rendering the bootstrap4 templates many, many times. I think this is what is killing my performance (i.e. 3-4 minutes to load an inline formset with 100 forms in it) How should I replace the include tags to avoid the duplicate rendering? Should I use extend somehow? I can replace the include tags with the actual html from the bootstrap4

Django crispy forms not loading CSS

微笑、不失礼 提交于 2019-12-11 04:56:47
问题 I saw this question on SO: Django crispy-forms cannot find CSS, and followed all of the suggestions in the accepted answer, i.e.: 'crispy-forms' is listed under INSTALLED_APPS I'm not running a production server, so I'm not sure the collectstatic option applied (although I did run it) Also: I am trying to use the bootstrap template pack, so I added CRISPY_TEMPLATE_PACK = 'bootstrap' into my settings.py file. When I load the form created by the example from https://gist.github.com/maraujop

Bootstrap Datepicker Example

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 04:24:30
问题 I cannot seem to get the bootstrap datepicker from http://www.eyecon.ro/bootstrap-datepicker/ to work using the example from https://gist.github.com/maraujop/2812529. The only thing I am unsure of is where to put the datepicker folder after downloading it? I put it in my static folder and while I get no errors the only thing that shows up on my form for a date field is a blank looking box next to the field but nothing comes up when pressing it. This doesn't seem like it should be that hard

How to spread form fields on two column layout in django-crispy-forms?

谁都会走 提交于 2019-12-11 03:54:42
问题 I have received a few recommendation to use django-crispy-forms for creating forms in Django. I have been looking for a couple of hours into the documentation and can't figure out a way how to spread the form fields over two columns. Looking at this example here helper = FormHelper() helper.form_class = 'form-horizontal' helper.layout = Layout( Field('text_input', css_class='input-xlarge'), Field('textarea', rows="3", css_class='input-xlarge'), 'radio_buttons', ... ) I can see how the

Adding Attribute to crispy forms django

♀尐吖头ヾ 提交于 2019-12-11 03:28:32
问题 Hey guys I am using bootstrap switch and it looks like if I want to add a label I need to: <input name="switch-labelText" type="checkbox" data-label-text="Label"> I am using crispy forms and I can see that I can do add attribute using the Field like so: Field('field_name', css_class="black-fields") This all makes sense to me but I can't seem to add data-label-text. So my question is can I make a custom attribute with crispy forms? Here is my form: class InstanceCreationForm(forms.Form): some

How to display Django SelectDateWidget on one line using crispy forms

亡梦爱人 提交于 2019-12-10 14:08:40
问题 I am trying to display the 3 select fields that are rendered out using Django SelectDateWidget on one line. When I use crispy forms, they are all on separate rows. Is there a way to use the Layout helper to achieve this? Thank you! class WineAddForm(forms.ModelForm): hold_until = forms.DateField(widget=SelectDateWidget(years=range(1950, datetime.date.today().year+50)), required=False) drink_before = forms.DateField(widget=SelectDateWidget(years=range(1950, datetime.date.today().year+50)),

Rendering field errors in django-crispy-forms with inline forms

馋奶兔 提交于 2019-12-10 03:47:05
问题 I'm using bootstrap3 as the default template pack in django_crispy_forms, and trying to render a form with the crispy tag: {% crispy form %} My form class has the following helper attributes: class TheForm(forms.Form): adv_var = forms.CharField(label="variable", max_length=70) value = forms.FloatField() def __init__(self, *args, **kwargs): super(TheForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_class = 'form-inline' self

Bootstrap3 inline forms in django-crispy-forms not showing form errors

限于喜欢 提交于 2019-12-10 02:58:56
问题 I am using django-crispy-forms to render a Bootstrap3 inline form (code shown below), but the errors upon form submission (like skipping required fields) are not being shown. They do in normal and horizontal form layouts. Could someone please suggest the possible reason(s)? Models.py class Person(models.Model): name = models.CharField(max_length=500) city = models.CharField(max_length=50) country = models.CharField(max_length=50) email = models.EmailField(blank=True) Forms.py class EntryForm