Skip to main content

custom widgets for Django-Forms/Filter

Project description

acdh-django-widgets

acdh-django-widgets is a Django app providing a collection of custom widgets for Django-Forms/Filter

Installation/Usage

Install the package e.g.

pip install acdh-django-widgets

add acdh-django-widgets to your INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "acdh-django-widgets",
    ...
]

Widgets

MartinAntonMuellerWidget

This widget extends django_filters.widgets.RangeWidget to provide a one-line range input interface, separated with a 'Halbgeviertstrich' ('–'). It's designed for numeric range filtering where two input fields (min and max) are displayed in a single line. It is named after @martinantonmueller because he likes the 'Halbgeviertstrich' ('–').

from acdh_django_widgets.widgets import MartinAntonMuellerWidget

class MyCustomFilter(FilterSet):
    
    start_date__year = RangeFilter(
        label=" Zeitraum: Anfang – Ende (z. B. 1862–1931)",
        widget=MartinAntonMuellerWidget
    )
    

DateRangePickerWidget

A custom DateRangeWidget that renders a date range picker using a template. This widget extends django_filters.widgets.DateRangeWidget to provide a date range picker interface. It uses a custom template for rendering the widget and allows setting minimum and maximum date values.

from acdh_django_widgets.widgets import DateRangePickerWidget

class MyCustomFilter(FilterSet):
    decission_date = django_filters.DateFromToRangeFilter(
        help_text=CourtDecission._meta.get_field("decission_date").help_text,
        label=CourtDecission._meta.get_field("decission_date").verbose_name,
        widget=DateRangePickerWidget
    )

RangeSliderWidget

A Django widget that renders a range slider using noUiSlider. This widget extends django_filters.widgets.RangeWidget to create an interactive range slider for selecting numeric ranges. It uses the noUiSlider JavaScript library for the slider functionality and wNumb for number formatting.

from acdh_django_widgets.widgets import RangeSliderWidget

class MyCustomFilter(FilterSet):
    year = django_filters.RangeFilter(
        help_text=YearBook._meta.get_field("year").help_text,
        label=YearBook._meta.get_field("year").verbose_name,
        widget=RangeSliderWidget(
            attrs={"min": "1900", "max": "2030", "hide_input_fileds": False}
        ),
    )

[!IMPORTANT]
The templates used in those widgets are using bootstrap5 classes so ideally those widgets are used with django-crispy-forms and crispy-bootstrap5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acdh_django_widgets-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acdh_django_widgets-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file acdh_django_widgets-0.1.0.tar.gz.

File metadata

  • Download URL: acdh_django_widgets-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for acdh_django_widgets-0.1.0.tar.gz
Algorithm Hash digest
SHA256 456ffb5b590f9809b477e06cfd739361400e4b7aa2884c95c241c0ea2d31e6d5
MD5 74293052749d98ad2a63ccddeaa9d43c
BLAKE2b-256 38ff7fcbce15eb3a1c080d044c62d0aa8c1beda7404fd520fdc55932ed98f21b

See more details on using hashes here.

File details

Details for the file acdh_django_widgets-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for acdh_django_widgets-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b6206fde4b808c5727c2bf368ae0289ac1f52c4930264781c942a4d104665bc
MD5 f50149ef942e29624a6f16b07c1a86f8
BLAKE2b-256 0014a867c29658aa51ab6034d8e6bceee60a8dd71e74889f43e5bd0e48e73484

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page