tables in django admin
Project description
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'
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-tablefield-0.0.5.tar.gz.
File metadata
- Download URL: django-tablefield-0.0.5.tar.gz
- Upload date:
- Size: 166.0 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
986920d9979c8bf993a4171e104a3025510317aa22ecea74627f55de06953d89
|
|
| MD5 |
64635e22a8070e8b468ad8d0dbe720f4
|
|
| BLAKE2b-256 |
d43eaa297b775d6908ce9731130cdd1d14c77f68236a5bcd0ed288864155ffac
|
File details
Details for the file django_tablefield-0.0.5-py3-none-any.whl.
File metadata
- Download URL: django_tablefield-0.0.5-py3-none-any.whl
- Upload date:
- Size: 215.4 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89c18cecad14694b6ae4ca464e6811a5e4c5f89fa8a206a1489cf0628318802e
|
|
| MD5 |
8046784035dc8e6449e0ee21867b1c5b
|
|
| BLAKE2b-256 |
661a8c5ec7b8348964c3260089ecf6b60e59f5e1978c409fb43ccdce71381c55
|