Skip to main content
# Django-Searchly-Tables

A simple Django app that adds search and sort to HTML tables.

I like using simple views, but it should work with class-based views as well (but I haven't tested it).

## Example

Add `searchly_tables` to your `INSTALLED_APPS`:

INSTALLED_APPS = (
...,
"searchly_tables",
)

In your view.py, import searchly_tables, add a new table to a view,
and specify for which model you would like to use it:

from django.shortcuts import render

from example.model import ExampleModel
from searchly_tables.tables import SearchlyTable

def view(request):
table = SearchlyTable(module="exampleapp.models", model="ExampleModel", field_filters=field_filters)
table.labels = {'baseField1': 'labelForBaseField1', 'foreignkey_relationship': 'labelForForeignKeyRelationship', 'baseField2': 'labelForBaseField2'}

# Optional links to models in fields
table.field_links = {'baseField2': ['app:view': 'url_parameter']}
if request.POST:
table.post(request.POST, filter=True, sort=True)
return render(request, 'example/table.html', {'table': table})

Then add the table to your template like this:

<form action="#" method=POST>
{% csrf_token %}
{{ table.searchbar|safe }}
<table>
{{ table.header|safe }} {{ table.body|safe }}
</table>
</form>

And that's it! Naturally, you can change the appearance of the table by applying CSS.

For instance `table.attrs['td'] = 'my_td_class'` would result in `<td class="my_td_class">` on all td elements in the table.
Django-searchly-tables currently only supports classes; sorry, no direct styles as of yet.
Also no direct access to a single element by id for most elements; the sole exception is `<td>`.

Here's the list of elements I use in the table:

> _thead_, _tbody_, _tr_, _th_, _td_, _input_, _button_, _select_, _option_

## FAQ

_Should I use this?_

Maybe? Probably not?

It's a super basic app with very little fuzz. The code is still all over the place.
If that's for you, cool. If you need more options in your tabling(?),
you should check out [django_tables2](https://django-tables2.readthedocs.io).

_Another table app? Haven't you heard about django\_tables2? It's way better and has tons of features!_

Yep, I agree. I even linked to it in my earlier answer!

_So, will this support feature X in the future? I really need that._

Probably not? I'm happy with the way it works now, apart from some minor issues (=code cleanup/documentation).
But you're welcome to fork it, if you need feature X. Or use django_tables2 (seriously, it's great!).


Metadata

Release files for django-searchly-tables 0.1

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-searchly-tables 0.1
File Size Uploaded
django-searchly-tables-0.1.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-searchly-tables 0.1
File Interpreter ABI Platform
django_searchly_tables-0.1-py2-none-any.whl Python 2 none any Details

Total release size: 12.0 kB

Release files / django-searchly-tables-0.1.tar.gz

Download URL django-searchly-tables-0.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c00a9b568ce0f857060612975cda8d6be290514916aa4d92644e5fff4dcf56b0
BLAKE2b-256 checksum
How to use checksums
2351649105ce5d6153737060d40adc2fe14c9e4dc668b367b17b10a070886f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

Release files / django_searchly_tables-0.1-py2-none-any.whl

Download URL django_searchly_tables-0.1-py2-none-any.whl
Size 6.4 kB
Tags Python 2
SHA-256 checksum
How to use checksums
8749402746010c57221cba7a89ae434065e9367a09967eec8ba8c10f40756e60
BLAKE2b-256 checksum
How to use checksums
24e1156ad156ec2cdcf8bfa72137f25fbef44da16dd596a5e37a3c2d3be32671
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

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