Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Created September 10, 2024 02:26
Show Gist options
  • Save douglasmiranda/c5d5a605ba42251b82da37b33231449d to your computer and use it in GitHub Desktop.
Save douglasmiranda/c5d5a605ba42251b82da37b33231449d to your computer and use it in GitHub Desktop.
Django forms.MultiWidget dict example
# this dict can be accessed in get_context()
{
"widget": {
"name": "publishing_dates",
"is_hidden": False,
"required": False,
"value": "[datetime.date(2024, 9, 5), datetime.date(2024, 9, 6), datetime.date(2024, 9, 7), datetime.date(2024, 9, 8)]",
"attrs": {
"class": "form-control",
"placeholder": "Data de publicação",
"id": "id_publishing_dates",
},
"template_name": "django/forms/widgets/multiwidget.html",
"subwidgets": [
{
"name": "publishing_dates_0",
"is_hidden": False,
"required": False,
"value": "2024-09-05",
"attrs": {
"class": "form-control",
"placeholder": "Data de publicação",
"id": "id_publishing_dates_0",
},
"template_name": "django/forms/widgets/date.html",
"type": "date",
},
# ...
],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment