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
0
votes
0 answers

how to display defalt value radio button in django form

My form allows the user to select between two roles. I struggle to understand why I cannot display it in the template. The model role default value, and the form role initial values, are both set to 'regular_user'. The models ae migated and the om…
donbonbon
  • 81
  • 1
  • 8
0
votes
1 answer

Django widget tweaks and variable attributes

Trying to include variables as attributes and values into a form field in a Django app template via a partial/component. There is a somewhat related thread but to my understanding it covers one side of the problem I am facing with…
0
votes
0 answers

ModuleNotFoundError: No module named 'widget_tweaks' with Django in VSCode Debugger

widget_tweaks is installed and added in INSTALLED_APPS in my setting.py. If I start the server with python3 manage.py runserver in the terminal it works. If I start the vscode debugger, I get this error in the Debug Console: File…
0
votes
3 answers

How i can get the value string from a drop down list

please how i can get correctly the value from the drop down list, i have used django-widget-tweaks library . this is the code of the field dropdown list that i want to get the value string from it:

{{ form.category_column.label_tag }}

0
votes
1 answer

Using django-widget-tweaks for multiple fields

I use django-widget-tweaks for validation like this {% if form.is_bound %} {% if form.action.errors %} {% render_field form.action class="form-control is-invalid" %} {% for error in form.action.errors %}
whitebear
  • 11,200
  • 24
  • 114
  • 237
0
votes
1 answer

Adding custom HTML elements around UserCreationForm's default elements

I am using widget_tweaks to add custom classes to input forms. But how do I add entire HTML elements like this to beautify the username ?
anjanesh
  • 3,771
  • 7
  • 44
  • 58
0
votes
0 answers

Trying to add an attribute to a Django crispy form input field

I'm attempting to add an attribute to a django crispy form using Django-Widget-Tweaks. I followed instructions, however, instead of adding the 'disabled' attribute to the existing field, it's adding a whole new field to the form with the same name,…
user1914490
0
votes
2 answers

Django filters - adjusting box width

With django_filters, I have my filterset, everything works fine it's just the display that I am stuck with (box width). As you can see below, I have changed the "size" attribute of some of the filter options - because the default is too wide. But…
0
votes
1 answer

How to visualize padding and margins in django templates and reducing white space between rows in bootstrap

I'm new to html and Django, and Bootstrap. I sometimes have trouble understanding the padding and margins. Is there some kind of clever way to use CSS to show the padding and margins visually. From what I can tell margins don't have a background…
UVphoton
  • 176
  • 1
  • 10
0
votes
1 answer

Django ValidationErrors not being displayed

I'm applying a validation for the datepicker when the user selects a future date. So far, the form does not save an invalid entry but the problem is that it doesn't display the error message for the field. This is what I've tried so…
0
votes
2 answers

django widget tweaks form control not action

when Making django board, I met the problem. django version is 3. I wanted form like this. but my code can't alert me "This field is required" But widget tweaks form-control wasn't working. which part is problem? My code is like this {% extends…
hyuk
  • 49
  • 4
0
votes
1 answer

Django: how to get username in template using django-tweaks

I have rendered a html form with widget_tweaks and i want the default value of the field to be the current username. #template {% if user.is_authenticated %}
{% render_field form.title value="{{ request.user }}"…
Kunal
  • 29
  • 2
  • 7
0
votes
1 answer

Django form doesn't show error on template page

My code is exactly the same as https://simpleisbetterthancomplex.com/series/2017/09/18/a-complete-beginners-guide-to-django-part-3.html#rendering-bootstrap-forms this. But when I click on the "post" button in the template it shows me the same page…
0
votes
1 answer

How do I escape single quotes in a django-widget-tweaks's render_field tag?

I'm trying to use django-widget-tweaks to render the following form field: {% render_field profile_form.bio class+="form-control" id="bio" rows="3" oninput="showBtn('updateProfile')" %} Into this: