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
0
votes
1 answer

Python/Django Forms: Dynamic variable creation and access for Form fields

I have a django form class only with one widget. I would like to give a name to this widget like but Django takes the name of the variable and gives it as a name to the widget. For example: class…
CodeArtist
  • 5,534
  • 8
  • 40
  • 65
0
votes
1 answer

Change CharField value after init

I have a page "A" with some CharField to fill programmatically. The value to fill come from another page "B", opened by javascript code executed only when the page is showed (after the init). This is the situation: page A __init__ during the init,…
DeLac
  • 1,068
  • 13
  • 43
0
votes
1 answer

Create custom django widget for timefield with now option

I have models with datetimefields and timefields. When the user interacts with these fields in a form they often just need to enter the current time. I need a now link almost exactly like what shows up in the django admin, so the user can just click…
rsp
  • 811
  • 2
  • 12
  • 32
0
votes
1 answer

How do I override django.contrib.comments field widgets?

I'm not looking to add inline styles to the comment field in my comment form. I'm looking for a way to add the placeholder attribute to my field. What's the proper way to do this? I was searching for a way to add/modify the widgets for the…
wulymammoth
  • 8,121
  • 4
  • 19
  • 19
0
votes
1 answer

Create a select widget in two parts, the first selecting items in the second dynamically

Is there any pre-done widget to incorporate into my django code which create an very special widget? Let's say that I have a database with # this is simplified code to keep only problematic stuff #model.py class Company(models.Model): name …
MUY Belgium
  • 2,330
  • 4
  • 30
  • 46
0
votes
0 answers

Django hidden field input, custom widget w/media rendering issues

I have a Django widget; it is a hidden input text field that has a JavaScript media file associated with it. This JavaScript media creates an ajax file uploader and requires 1 parameter; the id of the element it should append to. Upon a successful…
zallarak
  • 5,287
  • 7
  • 38
  • 54
0
votes
2 answers

Django; adding variable to media files in a custom widget

I want to make a widget that has some media files, and I want to be able to pass in parameters that the media files have access to. # in forms.py class aCustomWidget(forms.TextInput): class Media: css = { 'all':…
zallarak
  • 5,287
  • 7
  • 38
  • 54
0
votes
1 answer

Django DateTimePicker only shows up for superusers inside my app

I'm using django DateTimePicker widget -- AdminSplitDateTime() -- in event creating app, every thing goes fine when the loged in user has superuser permissions, but when normal user tries to access the creating form the widget don't show up. I don't…
UXE
  • 2,374
  • 2
  • 18
  • 17
0
votes
1 answer

How to pass a variable to an inherited class in Python/Django?

This may be more of an OO Python question. But it came from this question I asked regarding Django. So @burhan advised that instead of manually writing out my custom