Questions tagged [django-widget]

Django widgets handle the rendering of the HTML for form fields

A widget is Django’s representation of a HTML input element. The widget handles the rendering of the HTML, and the extraction of data from a GET/POST dictionary that corresponds to the widget. -- https://docs.djangoproject.com/en/dev/ref/forms/widgets/

Django includes a number of built in widgets, including TextInput, RadioSelect and CheckboxInput. It is easy to change the way a form field is displayed by declaring the widget when you define your Django form.

For example, if you have a form ChoiceField, where the user can choose from a list of options, your choice of widget determines whether this is rendered as a dropdown menu, or a list of radio buttons.

If custom behavior is required, Django's built in widgets can be subclassed and extended.

329 questions
1
vote
2 answers

Display image from ImageField by means of form BUT with Upload button

I've been looking for a solution for a while. I saw this solution to show the image instead of just the link to the image: Display image from ImageField by means of form But now I need to add a button so they can upload a new picture. Any solution…
1
vote
0 answers

Formset with per field widget selection

I am making a front end for custom testing framework. Each test has some associated scripts and each script has some associated parameters and each parameter has a parameter type. I want to be able to create a form to edit all of the parameters…
Odemia
  • 11
  • 2
1
vote
1 answer

How can I write widget for horizontal displaying multiple checkbox?

I have a form with multiple checkbox. But they are vertical displaying by default. I want to display their horizontally. I need to create custom widget for this task. I found a default code of CheckboxSelectMultiple…
unknown
  • 252
  • 3
  • 12
  • 37
1
vote
2 answers

What does the error 'Enter a list of values.' mean? (Using jQuery datetimepicker in django admin form)

Edit: it seems that when we use a DateTimeField in django, it expects two inputs, one with the date, and one with the time like this: So I'll just create two fields, one for the time and one for the date, will post an answer if it works as…
Paul Choppin
  • 116
  • 1
  • 11
1
vote
1 answer

Django Map Widgets drawing polygons

I'm just wondering, what is the name of the polygon field in the django-map-widgets module for GeoDjango and whether it supports drawing polygons?
kiwis
  • 65
  • 1
  • 9
1
vote
0 answers

Django form widget : submit onchange

I have a Django form with django-select2 and I would like to submit this one, not with a submit button but with onchange widget attribute. I tried to write this : class ManageDocForm(forms.Form): def __init__(self, *args, **kwargs): …
Essex
  • 6,042
  • 11
  • 67
  • 139
1
vote
1 answer

How to change django-autocomplete-light number of loaded objs by default?

By default, the ajax behavior in autocomplete queries 10 first objs of the list and by scrolling you would see further next 10 results. But the scrolling doesn't work smoothly so I need to actually see all the result on the list by default. (it's…
1
vote
1 answer

Testing Form Field Widget Type

I'm writing tests form a Django model form: class TemplateFieldTextForm(forms.ModelForm): class Meta: model = TemplateFieldText fields = [] def __init__(self, *args, **kwargs): super(TemplateFieldTextForm,…
Daniel Holmes
  • 1,952
  • 2
  • 17
  • 28
1
vote
3 answers

How to change NumberInput widget width in Django?

I'm trying to change the width of NumberInput and TextInput widgets: class MyModelAdmin(admin.ModelAdmin): formfield_overrides = { models.FloatField: {'widget': NumberInput(attrs={'size':'10'})}, models.CharField: {'widget':…
Duncan
  • 191
  • 14
1
vote
1 answer

how to add markers and center map in signup form django-map-widget

Using django-map-widget to render a map widget in forms. it works fine, but... I want to trigger the map in two ways (dynamically via javascript): trigger to re-center map on x,y trigger to add a marker to map on x,y I tried so many ways, but i…
1
vote
0 answers

django widget.type is incorrect in custom widget

I'm new to django. I'm going to use a custom widget for the check box. Here is my form.py: class SupervisorForm(forms.Form): is_manager = forms.BooleanField(label=_("manager"), required=False) I searched through whole project and realized that…
Hamed Salimian
  • 791
  • 2
  • 11
  • 28
1
vote
2 answers

Django custom (multi)widget input validation

What is the correct method for validating input for a custom multiwidget in each of these cases: if I want to implement a custom Field? if I want to use an existing database field type (say DateField)? The motivation for this comes from the…
user257111
1
vote
2 answers

How can I get the Django SplitDateTimeWidget to recognize AM/PM inputs?

I can't for the life of me figure out how to get the SplitDateTimeWidget (link to ref doc) to recognize AM/PM inputs. I've tried both the template-style input: widgets={'start_datetime':forms.SplitDateTimeWidget(time_format='h:i A')} and the…
Cyclic
  • 163
  • 2
  • 8
1
vote
2 answers

manytomany filter horizontal didn't work django admin

Getting below error while add a field in LabelLink model Currently I am working on django-cms and want to change current admin widget. IntegrityError at /admin/myapp/labellinkmodel/add/ NOT NULL constraint failed:…
Somil
  • 1,921
  • 1
  • 21
  • 35
1
vote
0 answers

How create custom tree widget for ModelMultipleChoiceField in django?

In my form I have function field which is ModelMultipleChoiceField where I want to add selected by user functions. As queryset function field take all objects of Group. Can someone help me to create custom widget as the picture below for that field?…
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193