Skip to content

Django Filtered-Model-Formset-Tables: a collection of reusable Class-Based Views that integrate django-filter and django-tables2 with model formsets.

License

Notifications You must be signed in to change notification settings

powderflask/django-fmft

Repository files navigation

Django Filtered Model Formset Tables

PyPI Version Docs Status Tests

Re-usable Class-Based Views that integrate django-filter and django-tables2 with model formsets. Render and process a user-filterable, user-sortable modelformset in a table with just a few lines of code. Rainbows and unicorns!

Features

  • Use a ModelForm / formset to define editable fields, add / delete, extra forms, etc.
  • Use a FilterSet to define filters the formset's queryset
  • Use a Table to lay out the formset, define paging, sorting, etc.
  • Render the Table with its filtered formset in just a few lines of template code

Views

Note: Table.Column options linkify and empty_values are overridden for columns rendered as form fields

  • linkify is incompatible with a form field representation, so is disabled;
  • to ensure 'empty' form fields are rendered, empty_values is set to () (i.e., render all values)

Quick Start

  1. Install the django-fmft package from PyPI

    $ pip install django-fmft

    For other installation methods see Installation.

  2. Add 'fmft' to INSTALLED_APPS:

    INSTALLED_APPS = [
        ...,
        "fmft",
        "django_tables2",
        "django_filters",
        "extra_views",   # optional
           ...,
    ]

Get Me Some of That

MIT License

Check Out the Demo App

  1. pip install -e git+https://github.com/powderflask/django-fmft.git#egg=django-fmft
  2. python manage.py migrate demo
  3. python manage.py loaddata demo/fmft_fixture.json
  4. python manage.py runserver

Acknowledgments

Special thanks to BC Hydro, Chartwell, and all Contributors

Technology Colophon

This package just glues together the amazing functionality provided by django-filter, django-tables2, and django-extra-views.

Python3, Django, HTML5, CSS3, JavaScript

For Developers

$  pip install -r reqirements_dev.txt

Tests

$ pytest

or

$ tox

Code Style / Linting

$ isort
$ black
$ flake8

Versioning

Docs

Build / Deploy Automation

Known Issues

  • hidden form fields are rendered in first form field column - can't have dynamically hidden fields, hidden on some rows while visible in others, without a little magic.

TODO

My wish list...

  • write test for case where form field is not included in table E.g. as when DELETE field not included in export table

About

Django Filtered-Model-Formset-Tables: a collection of reusable Class-Based Views that integrate django-filter and django-tables2 with model formsets.

Resources

License

Stars

Watchers

Forks

Packages

No packages published