Skip to main content

PyPI version Build Status Coverage Status Downloads Supported Python versions License

django-splitdate

This app provides a form widget that uses three text inputs to enter the day, month and year of a date for a standard DateField. The field is based on Django’s forms.SplitDateTimeWidget.

Quick start

  1. Install django-splitdate:

    • From the pip repository: pip install django_splitdate

    • or directly from github: `pip install git+git://github.com/NB-Dev/django-splitdate.git

  2. Add django_splitdate to your INSTALLED_APPS:

    INSTALLED_APPS = (
        ...
        'django_splitdate',
    )
  3. (optional) Customize the Settings (see below)

  4. Use the SplitDateField in your Forms:

    from django_splitdate.forms import SplitDateField
    date = forms.SplitDateField()

Global Configuration

The SplitDateField can be configured globally in your settings.py file with the following options

SPLITDATE_ORDER (String or Dict):

Defines the ordering of the day, month and year fields.

The order of the fields is defined by a three character string, that contains the characters ‘d’(day), ‘m’(month), ‘y’(year) in the desired order.

The setting can either be such a string to be used on each SplitDateField no matter what language is selected, or a dictionary containing key, value pairs with a locale name as key and the corresponding order string as value to be used depending on the current locale

Default:

dict((
    ('en', 'mdy'),
    ('de', 'dmy')
))

SPLITDATE_PLACEHOLDER_DAY (String):

A string defining the placeholder of the day field.

Default: _('DD')

SPLITDATE_PLACEHOLDER_MONTH (String):

A string defining the placeholder of the month field.

Default: _('MM')

SPLITDATE_PLACEHOLDER_YEAR (String):

A string defining the placeholder of the year field.

Default: _('YYYY')

Widget configuration

If you want to customize the widget of the SplitDateField, use the SplitDateWidget.

e.g. add a class:

from django_splitdate.forms import SplitDateField, SplitDateWidget
    date = forms.SplitDateField(widget=SplitDateWidget(attrs={'class':'myclass'}))

Additionally the widget takes the following local overwrites of the global configurations at initialization:

field_ordering (String or Dict):

Local overwrite for SPLITDATE_ORDER. Possible values, see above.

placeholder_day (String):

Local overwrite for SPLITDATE_PLACEHOLDER_DAY. Possible values, see above.

placeholder_month (String):

Local overwrite for SPLITDATE_PLACEHOLDER_MONTH. Possible values, see above.

placeholder_year (String):

Local overwrite for SPLITDATE_PLACEHOLDER_YEAR. Possible values, see above.

Running the tests

The included tests can be run standalone by running the tests/runtests.py script. The only requirement for this is Django >= 1.7. If you also want to run coverage, you need to install it before running the tests

Metadata

Release files for django-splitdate 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-splitdate 0.1.8
File Size Uploaded Provenance Actions
django-splitdate-0.1.8.tar.gz 6.9 kB Without provenance Details for django-splitdate-0.1.8.tar.gz

Release files / django-splitdate-0.1.8.tar.gz

Download URL django-splitdate-0.1.8.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2720ec86aabcd7f0343454278e92225b804c441db484f19f3ceea96fc2cd18a0
BLAKE2b-256 checksum
How to use checksums
1f117d41fb59b78d80e624ec5960b4709a838a8df01b5e8d13e94e1464652ebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-splitdate 0.1.8

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.

Release history Release notifications | RSS feed

This release

0.1.8 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page