Django Duration field widget to handle duration field in the form
Project description
Django Duration Widget
This package provides a more natural way of defining duration fields in forms. It is derived from the work of Devang Padhiyar here and provides a Python2 compatible implementation.
When to use?
You can find duration field as below which is not far good for humans to use.
Django duration widget is used for simplifying Django model's Duration field.
Quick start
-
Install
django-durationwidget2usingpippip install django-durationwidget2 -
Add
durationwidgetto yourINSTALLED_APPSsetting like this::INSTALLED_APPS = [ ... 'durationwidget', ]
-
Make sure to set
APP_DIRStoTruein settings.pyTEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'templates'), ... ], 'APP_DIRS': True, # Setup this to True 'OPTIONS': { ... }, }, ]
-
Cheer up you are ready to use
TimeDurationWidgetas normal widget as below.from django import forms from durationwidget.widgets import TimeDurationWidget from .models import YourModel class CustomForm(forms.ModelForm): ... duration = forms.DurationField(widget=TimeDurationWidget(), required=False) class Meta: model = YourModel ...
It will render Duration field as below
TimeDurationWidget
duration = forms.DurationField(widget=TimeDurationWidget(
show_days=True, show_hours=True, show_minutes=True, show_seconds=True
), required=False)
Following keyword argument can be passed to show/ hide fields in duration widget.
By default all keyword arguments are set to
True
show_days : To display/ hide days field in widget
show_hours : To display/ hide hours field in widget
show_minutes : To display/ hide minutes field in widget
show_seconds : To display/ hide seconds field in widget
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-durationwidget2-1.0.6.tar.gz.
File metadata
- Download URL: django-durationwidget2-1.0.6.tar.gz
- Upload date:
- Size: 72.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
269efc3cd6eec7c1da20df14938a379a0c11605a9eecf671ec8afa5956b41760
|
|
| MD5 |
1b81448be9750a3c26416639dba948ba
|
|
| BLAKE2b-256 |
949ae3b747493199ee38534dd84c02bd9e32f83f1c1c71ded92535af7bc90d23
|
File details
Details for the file django_durationwidget2-1.0.6-py3-none-any.whl.
File metadata
- Download URL: django_durationwidget2-1.0.6-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0b1d1f2357a5ec3e5716a7f38c7ffd8638244fd3c89b0082cca2a95bad30014
|
|
| MD5 |
d861e6181bbee7cdfcadb89fb9e9ccbe
|
|
| BLAKE2b-256 |
4e797ca10321e1241c12154c53d1061cbbd6c35058d1b84dfbd1ca35e532423e
|