Package: django-datetime-widget2
django-datetime-widget2django-datetime-widget2is derived from the long-standingdjango-datetime-widgetproject of Alfredo Saglimbeni (asaglimbeni). It includes fixes that enable its use withDjango>=2.1includingDjango 3.django-datetime-widget2is a simple and clean picker widget forDateField,TimefieldandDateTimeFieldinDjangoframework. It is based onBootstrap datetime picker, and supports both Bootstrap 3 and Bootstrap 2 .django-datetime-widget2is perfect when you use aDateField,TimeFieldorDateTimeFieldin your model/form where is necessary to display the corresponding picker with a specific date/time format. Now it supportsDjangolocalization.Available widgetsDateTimeWidget: display the input with the calendar and time picker.DateWidget: display the input only with the calendar picker.TimeWidget: display the input only with the time picker.See Demo pageRequirementsBootstrap2.0.4+ and 3.2.0jQuery1.7.1+ScreenshotsDecade year viewThis view allows the user to select the year in a range of 10 years.Year viewThis view allows the user to select the month in the selected year.Month viewThis view allows the user to select the day in the selected month.Day viewThis view allows the user to select the hour in the selected day.Hour viewThis view allows the user to select the preset of minutes in the selected hour.
The range of 5 minutes (by default) has been selected to restrict button quantity to an acceptable value, but it can be overwritten by the <code>minuteStep</code> property.Day view - meridianMeridian is supported in both the day and hour views.
To use it, just enable the <code>showMeridian</code> property.Hour view - meridianInstallationInstall django-datetime-widget2 using pip. For example:pip install django-datetime-widget2Adddatetimewidgetto your INSTALLED_APPS.If you want to use localization:Set USE_L10N = True, USE_TZ = True  and USE_I18N = True in settings.pyAdd ‘django.middleware.locale.LocaleMiddleware’ to MIDDLEWARE_CLASSES in settings.pyWhen you create the widget add usel10n = True like attribute : DateTimeWidget(usel10n=True)Basic ConfigurationCreate your model-form and set  DateTimeWidget widget to your DateTimeFieldfrom datetimewidget.widgets import DateTimeWidget

class yourForm(forms.ModelForm):
    class Meta:
        model = yourModel
        widgets = {
            #Use localization and bootstrap 3
            'datetime': DateTimeWidget(attrs={'id':"yourdatetimeid"}, usel10n = True, bootstrap_version=3)
        }Downloadtwitter bootstrapto your static file folder.Add in your form template links to jquery, bootstrap and form.media:<head>
....
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <link href="{{ STATIC_URL }}css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <script src="{{ STATIC_URL }}js/bootstrap.js"></script>
    {{ form.media }}

....
</head>
<body>
    <form  action="" method="POST">
    {% csrf_token %}
    {{ form.as_table }}
    <input id="submit" type="submit" value="Submit">
    </form>
</body>Optional: you can add an option dictionary to DatetimeWidget to customize your input. For example, to have date and time with meridian:dateTimeOptions = {
'format': 'dd/mm/yyyy HH:ii P',
'autoclose': True,
'showMeridian' : True
}
widgets = {
    #NOT Use localization and set a default format
    'datetime': DateTimeWidget(options = dateTimeOptions)
    }!!! If you add ‘format’ into options and in the same time set usel10n as True the first one is ignored. !!!OptionsThe options attribute can accept the following:
* formatString.  Default: ‘dd/mm/yyyy hh:ii’The date format, combination of  P, hh, HH , ii, ss, dd, yy, yyyy.P : meridian in upper case (‘AM’ or ‘PM’) - according to locale filess : seconds, 2 digits with leading zerosii : minutes, 2 digits with leading zeroshh : hour, 2 digits with leading zeros - 24-hour formatHH : hour, 2 digits with leading zeros - 12-hour formatdd : day of the month, 2 digits with leading zerosyy : two digit representation of a yearyyyy : full numeric representation of a year, 4 digitsweekStartInteger.  Default: 0Day of the week start. ‘0’ (Sunday) to ‘6’ (Saturday)startDateDate.  Default: Beginning of timeThe earliest date that may be selected; all earlier dates will be disabled.endDateDate.  Default: End of timeThe latest date that may be selected; all later dates will be disabled.daysOfWeekDisabledString.  Default:  ‘’Days of the week that should be disabled. Values are 0 (Sunday) to 6 (Saturday). Multiple values should be comma-separated. Example: disable weekends:  ‘0,6’.autocloseString.  Default: ‘true’Whether or not to close the datetimepicker immediately when a date is selected.startViewInteger.  Default: 2The view that the datetimepicker should show when it is opened.
Accepts values of :‘0’  for the hour view‘1’  for the day view‘2’  for month view (the default)‘3’  for the 12-month overview‘4’  for the 10-year overview. Useful for date-of-birth datetimepickers.minViewInteger. Default: 0The lowest view that the datetimepicker should show.maxViewInteger. Default: 4The highest view that the datetimepicker should show.todayBtnBoolean.  Default: FalseIf true , displays a “Today” button at the bottom of the datetimepicker to select the current date.  If true, the “Today” button will only move the current date into view.todayHighlightBoolean.  Default: FalseIf true, highlights the current date.minuteStepInteger.  Default: 5The increment used to build the hour view. A button is created for each <code>minuteStep</code> minutes.pickerPositionString. Default: ‘bottom-right’ (other supported value : ‘bottom-left’)This option allows you to place the picker just under the input field for the component implementation instead of the default position which is at the bottom right of the button.showMeridianBoolean. Default: FalseThis option will enable meridian views for day and hour views.clearBtnBoolean.  Default: FalseIf true, displays a “Clear” button at the rigth side of the input value.CHANGELOG0.9.4VSupport for Django >= 2.10.9.3VFIX #48Python 3 support0.9.2VFIX #460.9.1Vpython options are correct converted to the javascript options.FIX #38 #40.code refactor and bug fixes.0.9VUpdate bootstrap datetime picker to the last version.CLOSE #20 (support bootstrap 2 and 3).CLOSE #17 TimeWidget.CLOSE #16 DateWidget.new clear button at the rigth side of the input value.add dateTimeExample django project.0.6VAdd Clear buttonFix TypeError bugSupport localizationUpdate static file with last commit of bootstrap-datetime-pickerupdate js lib, native localization, thanks to @quantum13autoclose is true by defaultContributeCheck for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is aContributor Friendlytag for issues that should be ideal for people who are not very familiar with the codebase yet.If you feel uncomfortable or uncertain about an issue or your changes, feel free to email @asaglimbeni and he will happily help you via email, Skype, remote pairing or whatever you are comfortable with.Fork and develop branch fromthe repositoryon GitHub to start making your changes to thedevelopbranch (or branch off of it).Please show that the bug was fixed or that the feature works as expected.Send a pull request and bug the maintainer until it gets merged and published. :)Your changes will be released on the next version of django_datetime_widget!TODOwidget for DateTime range.