Questions tagged [django-widget-tweaks]

django-widget-tweaks is the python package for Django to tweak the form field rendering in templates, not in python-level form definitions. Altering CSS classes and HTML attributes are supported.

django-widget-tweaks is the python package for Django to tweak the form field rendering in templates, not in python-level form definitions. Altering CSS classes and HTML attributes are supported. You can install it using

pip install django-widget-tweaks

You can find details in python software foundation https://pypi.org/project/django-widget-tweaks/ . For source code and other details please check github link.

54 questions
11
votes
5 answers

Widget tweaks error ModuleNotFoundError: No module named 'widget_tweaks' with Django forms

I am trying to customize my Django forms using widget tweaks for an app I'm building with a group and I keep getting an error: ModuleNotFoundError: No module named 'widget_tweaks' I don't understand why. I installed the module on my mac with $ pip…
Thao
  • 111
  • 1
  • 1
  • 4
5
votes
1 answer

Using django-widget-tweaks with Jinja2 template engine

I'm using django v1.11.7 with Jinja2 v2.10 as the template engine. In my website, I wish to render forms using bootstrap. I found out that django-widget-tweaks can be used for this integration. This package won't work with Jinja templates, since it…
rahul
  • 366
  • 7
  • 21
5
votes
1 answer

Use field label as placeholder with django-widget-tweaks

I am using django-widget-tweaks and unable to figure out how to add a field variable as placeholder, like the following:
{{ field|append_attr:"class:form-control"|append_attr:"placeholder:field.label" }} {% if…
Anupam
  • 14,950
  • 19
  • 67
  • 94
5
votes
4 answers

TemplateSyntaxError: widget_tweaks is not a valid library django

I am new to django and I am trying to trying to implement a form that uses widget-tweaks. I did install widget tweaks (I am using Ubuntu 14.04) sudo pip install django-widget-tweaks My settings file looks like this: INSTALLED_APPS =…
Tom
  • 2,545
  • 5
  • 31
  • 71
4
votes
1 answer

template tag 'add' requires 2 arguments, 1 provided

I have used add before but getting this strange error this time: django.template.exceptions.TemplateSyntaxError: add requires 2 arguments, 1 provided with the following code: {% render_field form.full_name type="hidden" class="form-control" \ …
Anupam
  • 14,950
  • 19
  • 67
  • 94
4
votes
3 answers

django apply widget for all fields

Is there a way to apply css class to ALL fields instead of doing the following for every single field. forms.py class UserColorsForm(forms.ModelForm): class Meta: model = UserColors exclude = ('userid',) widgets = { …
deathangel908
  • 8,601
  • 8
  • 47
  • 81
2
votes
1 answer

Can django widget_tweaks render out input as textarea box?

I want to render out an input box as textarea with widget_tweaks in Django. This is my code:
Didzis
  • 156
  • 1
  • 11
2
votes
2 answers

How to remove required from Django-Widget-Tweaks form field

I am trying to remove the required attribute from a django-widget-tweaks form. I tried: {% render_field form.legal_entity|attr:'required:false' placeholder=form.legal_entity.label class+="form-control" %} and {% render_field…
David
  • 646
  • 1
  • 7
  • 27
2
votes
0 answers

Add Font Awesome icon with label_tag

How do I add a Font Awesome icon like to the following {{form.date.label_tag}} which uses widget_tweaks? I know generally you'd just do it like this

Add

but I haven't had…
Reez0
  • 2,512
  • 2
  • 17
  • 39
2
votes
1 answer

Django widget tweaks 'render_field' not working

I have this form rendering template in django, and render_field is not working inside if-else: {% load widget_tweaks %} {% for field in form %}
{{ field.label_tag }} {% if form.is_bound %} …
tkhurana96
  • 919
  • 7
  • 25
2
votes
0 answers

How to use django-widget-tweaks render_field with Jinja?

I have successfully used django-widget-tweaks add_class as Jinja filter. I put the function into Jinja environment filters, like below. def environment(**options): env = Environment(**options) env.globals.update({ 'static':…
oon arfiandwi
  • 515
  • 1
  • 8
  • 21
1
vote
0 answers

django-widget-tweaks: removing "required" for check-box-input

Getting "Please check this box if you want to proceed" error when I want to submit False value for the checkbox. I am using django-widget-tweaks, forms-Form for form. Model has is_active = models.BooleanField(default=True, null=True) Form has…
edkim8
  • 11
  • 1
1
vote
0 answers

How to select an option of choice field with a value which is rendered by render_field in django template? I'm using django-widget-tweaks package

I trying to render fields by looping form class field using django-widget-tweaks render_field. Fields are rendered as excepted, however, unable to select an option for combo box. Any Idea to make an option selected by value given. I have used value…
Dhaaz
  • 27
  • 4
1
vote
0 answers

django-widget-tweaks error while rendering in Django 2.1

While trying to use OSMField from django-osm-field and rending it with with django-widget-tweaks I am getting this error: File "/usr/local/lib/python3.7/site-packages/django/forms/boundfield.py", line 93, in as_widget …
ketimaBU
  • 901
  • 4
  • 15
  • 35
1
vote
2 answers

how to use django widget tweaks and combine template class string and widget attr attributes string name

I am trying to customise a django form for use with bootstrap 4, custom html layout & per field class or id names on the FormModel defintion I have the following html {% for hidden_field in form.hidden_fields %} {{ hidden_field }} {% endfor…
Chris Barry
  • 4,564
  • 7
  • 54
  • 89
1
2 3 4