Listable



Listable

Latest version

A pioneering and award-winning real estate development firm with an urban focus and extensive historic rehabilitation expertise, KFK Group has been developing impactful residential. Download LISTABLE v1.11.0 – A Friendly Directory WordPress Theme Nulled Free Version 1.11.0 - Feb 12, 2020 Hey, Vincent Van Gogh said: Great things are done by a series of small things brought together. We deeply believe that, so in the last few weeks we worked to get new improvements for our Listable theme. Proudly powered by WordPress and Listable by Pixelgrade. This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.

  1. Listable is a Django package to make the integration of your Django models with Datatables.js easy. Django-listable was motivated by my repeated need to generate sortable and filterable tables from my Django models for CRUD apps.
  2. Explore some of the best listings from around the city from our partners and friends.

Released:

A reusable Django app to make integrations with the DataTables javascript library easy.

Project description

About

Listable

Listable is a Django package to make the integration of your Djangomodels with Datatables.js easy.

Django-listable was motivated by my repeated need to generate sortableand filterable tables from my Django models for CRUD apps.

The idea is that you should easily be able to go from a model like this:

to a filterable/orderable table in a template like this with as little code as possible:

There are a couple of other similar projects worth checking out to see if they fit yourneeds better:

Settings

Listable currently has 4 settings you can configure to be usedas default values for your table (they can be overriden in the listable template tag).

LISTABLE_DOM

Default datatables sDOM parameter to use. By default listable uses the Bootstrap 3 dom below.:

LISTABLE_PAGINATION_TYPE

LISTABLE_STATE_SAVE

Enable sticky filters by default.:

LISTABLE_PAGINATE_BY

Default page size.:

Usage

There’s four steps to using django-listable

  1. Including listable in your settings.INSTALLED_APPS
  2. Create a view by subclassing listable.views.BaseListableView
  3. Connect the view to a url pattern in your apps urls.py
  4. Include the listable template tag in a template

These steps will demonstrated below assuming we havea Django application called staff and we want to create a page on oursite with a list of staff and the department and business they belong to.

with the following models defined:

A full functional example can be found in the demo app included withdjango-listable.

Adding listable to settings.INSTALLED_APPS

To start using django-listable add listable to your INSTALLED_APPS:

Defining a Listable view

To define a listable view, sublcass listable.views.BaseListableViewand set the model that is to be used as the source of data:

Defining Columns for your table

Every listable view must define one or more fields to be displayed as columns in the table.listable fields are defined in a manner similar to ModelForms:

fields

Fields defines an iterable of the columns that you want to display in the table,these fields can either be fields on your model, foreign key lookups, the nameof a callable on your view, the name of a callable on your model or the result of an extraquery.

widgets

Widgets is a dictionary mapping a field to a search widget type. Currently you can useeither text (default) or select inputs. For example:

The choices available in a select widget are currently automaticallypopulated although this will change to allow manual configuration of choicesin the future. The choices are populated based on either the choices optionfor a model field or in the case of a foreign key all the values of the foreignkey lookup. (I hope to make this more flexible in the future)

search_fields (optional)

Search fields are a mapping of field names to the django filter syntax that shouldbe used for searching the table. This can either be a string, an iterable ofstrings or a falsy value to disable searching on that field. For example:

if a field is not declared in search_field’s it a filter using icontains is assumed.

order_fields (optional)

Order fields allows you to define how a column should be ordered (similar toDjango’s ordering or order_by). For example:

headers (optional)

Headers is a mapping of field names to the column name to be displayed. For example by defaulta field name of department__business__name would be converted to “Department Business Name” but thatcould be overriden like so:

select_related

Allows you to use Django’s queryset select_related option for reducing database queries. e.g:

prefetch_related

Allows you to use Django’s queryset prefetch_related option for reducing database queries. e.g:

get_extra

Due to a bug with pagination, using an extra query will result in your entire table being loaded into memory beforebeing paginated :(

You may define a callable get_extra method on your view that should return a dictionary suitablefor use in the Django queryset’s extra method. For example:

A more complex example is given in the “Complete Example” sample below.

Formatting fields

The order in which listable tries to find a method for formatting a field for display is as follows:

  1. A method on the actual view:

  2. A get_{field}_display callable on the model.

  3. A callable on the model:

  4. A field on the model.

A listable column is defined using the listable.views.Column data structure.A Column is essentially a namedtuple with the following fields (detailed descriptions below):

Including the listable template tag in a template

To include listable in your templates you need to load the listable templatetags and include the listable_css, a placeholder for the listable tableand the listable tag which tells the template the name of the view to wire the table to.:

with the example above requiring a url something like:

Arguments to the listable tag

The listable tag currently has 1 required argument and five optional keyword args.A full example of the listable template tag looks like:

dom

Overrides the default Datatables sDOM parameter to use.

pagination_type

Overrides the default Datatables sDOM parameter to use.

save_state

Save state enables/disables sticky filters in DataTables.:

css_table_class

Add a css class to your datatables table e.g.:

css_input_class

Add a css class to the datatables column filter inputs e.g.:

A Complete Example

Listable Theme Wordpress

This is a complete example of a django-listable table. It is includedas a demo app under the django-listable/listable-demo/

views.py

History

0.5.0 (2021-02-03)

  • Fixed a same site cookie issue
  • Fixed a bug where select dropdowns were being truncated by bottom of page
  • Added a get_fields method to set fields dynamically
  • Fix an issue with incorrect timezones
  • Add support for Django 2-

0.4.3 (2017-05-11)

Fix values_to_dt to allow unicode

0.4.1 (2016-10-14)

Add fix for when using FORCE_SCRIPT_NAME setting

0.4.0 (2016-10-02)

Update to support Django 1.8-1.10 and Python 2.7-3.5

0.3.10 (2016-11-08)

Cast search term to lower case if case insensitive search requested to alloweasier filtering with extra queries.

0.3.9 (2016-09-27)

Fix formatting bug introduced by 0.3.8

0.3.7 (2016-08-25)

Add date range picker

0.3.6 (2016-06-29)

Add multi select and date select widgets (thanks to @ryanbottema)

0.3.5 (2016-06-22)

Fix filtering and count queries for django-mssql

0.3.3 (2015-04-12)

  • Fix filtering of None values for SELECT fields

0.3.1 (2015-02-25)

  • Fix issue with boolean field filtering

0.2.9 (2014-12-15)

  • Fix issue with namespaced urls

Listable Theme Free Download

0.2.6 (2014-10-30)

Listable Demo

  • add view args & kwargs to context to allow full reverse

0.2.0 (2014-10-29)

  • Complete overhaul of api

0.1.0 (2013-08-15)

  • First release on PyPI.

Release historyRelease notifications | RSS feed

0.5.0

0.4.3

0.4.2

0.4.1

0.4.0

0.3.10

0.3.9

0.3.8

0.3.7

0.3.6

0.3.5

0.3.4

0.3.3

0.3.2

0.3.1

0.3.0

0.2.10

0.2.9

0.2.8

0.2.7

0.2.6

0.2.5

0.2.4

0.2.3

0.2.2

0.2.1

0.1.4

0.1.3

0.1.0

Download files

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

Files for django-listable, version 0.5.0
Filename, sizeFile typePython versionUpload dateHashes
Filename, size django_listable-0.5.0-py3-none-any.whl (408.1 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size django-listable-0.5.0.tar.gz (399.4 kB) File type Source Python version None Upload dateHashes

Listable Skills

Close

Hashes for django_listable-0.5.0-py3-none-any.whl

Hashes for django_listable-0.5.0-py3-none-any.whl
AlgorithmHash digest
SHA256bcd4fd6d51d4f6cf799ebeb8f3a4a25d70596f6125e443625a8ab8558d169ee1
MD533e73354bf59aab7ff00c9dc88a929ab
BLAKE2-256eef848b9fc3460d2fc7c46dfaee4203fed93b5aabde9268962e77a2a42aceee7
Close

Listable Synonym

Hashes for django-listable-0.5.0.tar.gz

Listable Demo

Hashes for django-listable-0.5.0.tar.gz
AlgorithmHash digest
SHA256865bbc29a9765e99e03b66b58f9b30e65151b68e8c017bc70d8e7ffff92a1ea2
MD5d291524354d48112aedb9f372cb08764
BLAKE2-256de9b7ecad14773f37ef9378fe2d30c80e9f8483a49a62892977510c8bf14686f