Datepick
Django-datepick is a Django app to add a date, time and datetime pickers to your forms.
Install
Install the app with pip install django-datepick.
Usage with forms
Change the widget used in your forms.py to use the widgets included in this app:
from django import forms
from datepick import widgets
class MyForm(forms.Form):
date_field = forms.DateField(widget=widgets.DateInput)
datetime_field = forms.DateTimeField(widget=widgets.DateTimeInput)
time_field = forms.TimeField(widget=widgets.TimeInput)
Usage with models
Change the field used in your models.py to use the fields from this app:
from django.db import models
from datepick import fields
class MyDateModel(models.Model):
d = fields.DateField()
dt = fields.DateTimeField()
t = fields.TimeField()
Override the admin widget
Same as with any widget, register the model overriding the widget(s) in admin.py:
from datepick.widgets import DateInput, SplitDateTimeWidget, TimeInput
class MyDateModelAdmin(admin.ModelAdmin):
formfield_overrides = {
models.DateField: {"widget": DateInput},
# DON'T models.DateTimeField: {"widget": DateTimeInput}
models.DateTimeField: {"widget": SplitDateTimeWidget}
models.TimeField: {"widget": TimeInput},
}
DateTimeInput doesn’t work in the admin, as it expects a multivalue field.
Why?
Each time you use a date field in Django, the form is a text input. Any frontend would like a datepicker of somekind. Turns out browsers and cellphones already have a datepicker. It looks like this in a browser:
And looks like this in a cellphone:
It doesn’t need Javascript or extra CSS.
More info:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
Metadata
Release files for django-datepick 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-datepick-0.1.2.tar.gz | 3.8 kB | Without provenance | Details for django-datepick-0.1.2.tar.gz |
Release files / django-datepick-0.1.2.tar.gz
| Download URL | django-datepick-0.1.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e82c2c421f2bd88b4299aacaca27bd4e9cbd5b7a9f36adeb2e5e07913ed5a96
|
|
BLAKE2b-256 checksum How to use checksums |
eee183c8056c58a458ae660ba2076b02e859ae7aec243fac41f60d1a7a176e34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for django-datepick 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.