Skip to main content

Django Tablefield

It uses Handsontable JS library (0.38.1 version. MIT Lisence). It is almost like wagtail's TableBlock.
But for plain Django and added functional of merge cells and alignment.

Installation

pip install django-tablefield
# or latest version
pip install git+https://github.com/raagin/django-tablefield.git

Using

# settings.py
INSTALLED_APPS = [
    ...
    'tablefield',
    ...
]

# models.py
from tablefield.fields import TableField

class MyModel(models.Model):
    table = TableField(verbose_name='Table')

In templates

{% load tablefield_tags %}
{% tablefield_render mymodel.table %}

Options

Default options is:

DEFAULT_TABLE_OPTIONS = {
    'minSpareRows': 0,
    'startRows': 3,
    'startCols': 3,
    'colHeaders': False,
    'rowHeaders': False,
    'mergeCells': True,
    'contextMenu': [
        'row_above',
        'row_below',
        '---------',
        'col_left',
        'col_right',
        '---------',
        'remove_row',
        'remove_col',
        '---------',
        'mergeCells',
        '---------',
        'alignment',
        '---------',
        'undo',
        'redo'
    ],
    'editor': 'text',
    'stretchH': 'all',
    'height': 200,
    'renderer': 'html',
    'autoColumnSize': False,
}

As you see, default renderer is html.
You read about it: https://handsontable.com/docs/1.18.1/Options.html#renderer

You may set your options:

class MyModel(models.Model):
    table = TableField(
        table_options = {
            'minSpareRows': 0,
            'startRows': 3,
            'startCols': 3,
            'colHeaders': False,
            'rowHeaders': False,
            'mergeCells': True,
            'contextMenu': [
                'row_above',
                'row_below',
                '---------',
                'col_left',
                'col_right',
                '---------',
                'remove_row',
                'remove_col',
                '---------',
                'mergeCells',
                '---------',
                'alignment',
                '---------',
                'undo',
                'redo'
            ],
            'editor': 'text',
            'stretchH': 'all',
            'height': 200,
            'renderer': 'html',
            'autoColumnSize': False,
        },
        verbose_name='Table'
        )

Metadata

Release files for django-tablefield 0.0.5

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-tablefield 0.0.5
File Size Uploaded
django-tablefield-0.0.5.tar.gz 166.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-tablefield 0.0.5
File Interpreter ABI Platform
django_tablefield-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 381.4 kB

Release files / django-tablefield-0.0.5.tar.gz

Download URL django-tablefield-0.0.5.tar.gz
Size 166.0 kB
Tags Source
SHA-256 checksum
How to use checksums
986920d9979c8bf993a4171e104a3025510317aa22ecea74627f55de06953d89
BLAKE2b-256 checksum
How to use checksums
d43eaa297b775d6908ce9731130cdd1d14c77f68236a5bcd0ed288864155ffac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / django_tablefield-0.0.5-py3-none-any.whl

Download URL django_tablefield-0.0.5-py3-none-any.whl
Size 215.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89c18cecad14694b6ae4ca464e6811a5e4c5f89fa8a206a1489cf0628318802e
BLAKE2b-256 checksum
How to use checksums
661a8c5ec7b8348964c3260089ecf6b60e59f5e1978c409fb43ccdce71381c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

1 release file

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