Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django version >= 1.8
Reason this release was yanked:
It has breaking changes https://github.com/monim67/django-bootstrap-datepicker-plus/issues/66
Project description
This django widget contains Bootstrap 3, Bootstrap 4 and Bootstrap 5 Date-Picker, Time-Picker, DateTime-Picker, Month-Picker and Year-Picker input with date-range-picker functionality for django version >= 1.8. The widget implements bootstrap-datetimepicker v4 to show bootstrap-datepicker in django model forms and custom forms which can be configured easily for date-range selection.
Demo
Getting Started
Prerequisites
Python >= 3.6
Django >= 1.8
Bootstrap >= 3
jquery >= 1.7.1
Installing
Install the PyPI package via pip
pip install django-bootstrap-datepicker-plus
Add bootstrap_datepicker_plus to the list of INSTALLED_APPS in your settings.py file.
INSTALLED_APPS = [
# Add the following
'bootstrap_datepicker_plus',
]
This installation instruction assumes you have jQuery and Bootstrap JS/CSS files present in your template and you are using form.media in your django template. If not you have to configure your template.
Next Steps
Usage
Usage in Generic View
# File: views.py
from bootstrap_datepicker_plus import DateTimePickerInput
from django.views import generic
from .models import Question
class CreateView(generic.edit.CreateView):
model = Question
fields = ['question_text', 'pub_date']
def get_form(self):
form = super().get_form()
form.fields['pub_date'].widget = DateTimePickerInput()
return form
Advanced Usage
Types of DatePickers
The widget contains all types of date-picker you may ever need.
# File: forms.py
from bootstrap_datepicker_plus import DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput
from django import forms
class EventForm(forms.ModelForm):
class Meta:
model = Event
fields = ['start_date', 'start_time', 'start_datetime', 'start_month', 'start_year']
widgets = {
'start_date': DatePickerInput(),
'start_time': TimePickerInput(),
'start_datetime': DateTimePickerInput(),
'start_month': MonthPickerInput(),
'start_year': YearPickerInput(),
}
Implement date-range-picker
DatePickers can be linked to select a date-range or time-range.
# File: forms.py
from bootstrap_datepicker_plus import DatePickerInput, TimePickerInput
from django import forms
class EventForm(forms.ModelForm):
class Meta:
model = Event
fields = ['name', 'start_date', 'end_date', 'start_time', 'end_time']
widgets = {
'start_date':DatePickerInput().start_of('event days'),
'end_date':DatePickerInput().end_of('event days'),
'start_time':TimePickerInput().start_of('party time'),
'end_time':TimePickerInput().end_of('party time'),
}
Customization
Contributing
License
This project is licensed under Apache License 2.0 - see the LICENSE file for details.
Acknowledgments
This project implements Eonasdan/bootstrap-datetimepicker to display date-pickers. The project was initially forked from pbucher/django-bootstrap-datepicker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-bootstrap-datepicker-plus-3.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffe2fa6568b51cdc9f5c6e3a71d8e0914e2f5b5f8f2b1793cbfe1afd704b7de9 |
|
MD5 | 58d92d8875d7105cad5b42d7ff5dca7a |
|
BLAKE2b-256 | 4aaf5b78e9adfdd970fcf5482b92eed1cda589746a16e750c1d64c88064e0ec5 |
Hashes for django_bootstrap_datepicker_plus-3.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c590d840994c7ae4f78ab47471e5dd107d6aad456ca34f2f36dffa41eeb8b819 |
|
MD5 | 687e0c6b0d74fcbb9d2e439a33d0d162 |
|
BLAKE2b-256 | 2c9d7166ef25146f1230ca3972b781086599dc00da6e4dc17bf3ffa47a4ec17e |