Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput
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 >= 2.0. 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.
If you are not using Bootstrap use django-flatpickr instead.
Demo
Getting Started
Follow the Getting Started doc.
Head over to Usage section to see how to use it in forms and views.
Read detailed Documentation on ReadTheDocs
Looks complex to get started? Follow a Quick Walkthrough Tutorial
Getting errors? See Troubleshoot instructions
Usage
Usage in Generic View
# File: views.py
from bootstrap_datepicker_plus.widgets 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.widgets 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.widgets 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(),
"end_date": DatePickerInput(range_from="start_date"),
"start_time": TimePickerInput(),
"end_time": TimePickerInput(range_from="start_time"),
}
Customization
Contributing
License
This project is licensed under MIT 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 and later reworked completely under MIT Licence.
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
File details
Details for the file django_bootstrap_datepicker_plus-5.0.5.tar.gz
.
File metadata
- Download URL: django_bootstrap_datepicker_plus-5.0.5.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea5e2bc2137a72b57ba10d2a5f18373049b0d252052f921e5a76c260eaaa35ee |
|
MD5 | e6dd5965491ad4c50d3e4690b8842674 |
|
BLAKE2b-256 | 95f264abdea909b73daa386e0c631f023efd899e1b64e19bbc329a2ab2455d64 |
File details
Details for the file django_bootstrap_datepicker_plus-5.0.5-py3-none-any.whl
.
File metadata
- Download URL: django_bootstrap_datepicker_plus-5.0.5-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0818dcaca6824f2bc3b42b53e2cd0e42e9ceb2c8802254f9d38d4cce04b31d8 |
|
MD5 | dbec908f8ba7abf1f93e29c65708180f |
|
BLAKE2b-256 | 554627def8da80a9600194aeb90f8f609591e965c9fb82bfe64bdc832f8ddfe5 |