Skip to main content

Date and time widgets

Date and time widgets (dark theme)
Date and time widgets (light theme)

Drag the divider or use the arrow keys to compare themes.

Date and time widgets
Date and time widgets (dark theme)
Date and time widgets (light theme)

Drag the divider or use the arrow keys to compare themes.

  1. Date and calendar shortcut
  2. Time and clock shortcut
  3. Combined date and time input
  4. Separate date and time inputs
Date and time widgets

Django Chassis 1.0.23 · training site with Russian UI

  1. Date and calendar shortcut
  2. Time and clock shortcut
  3. Combined date and time input
  4. Separate date and time inputs

How to add it​

Declare the fields in catalog_demo/widget_gallery_form.py and pass the form to the Admin page context. In catalog_demo/templates/catalog_demo/widget_gallery.html, render the fields and include {{ gallery.media }} in extrahead with the Admin JavaScript catalog {% url 'admin:jsi18n' %}.

from django import forms
from django_chassis.widgets import (
DATE_INPUT_FORMAT, DATETIME_INPUT_FORMAT, TIME_INPUT_FORMAT,
DateInput, DateTimeInput, SplitDateTime, TimeInput,
)

class WidgetGalleryForm(forms.Form):
opens_on = forms.DateField(widget=DateInput(), input_formats=[DATE_INPUT_FORMAT])
opens_at = forms.TimeField(widget=TimeInput(), input_formats=[TIME_INPUT_FORMAT])
scheduled_at = forms.DateTimeField(
widget=DateTimeInput(), input_formats=[DATETIME_INPUT_FORMAT],
)
split_at = forms.SplitDateTimeField(
widget=SplitDateTime(), input_date_formats=[DATE_INPUT_FORMAT],
input_time_formats=[TIME_INPUT_FORMAT],
)

On the gallery page, try the calendar and clock. The split input returns one combined value after validation.