Djangotables is a simple library for generating html tables with Django Framework using model data like django forms.
Project description
djangotables
Djangotables is a simple library for generating html tables with Django Framework using model data like django forms.
Djangotables is a simple yet powerful library. A library based on forms generated by Django, if you are already familiar with django forms it will be very easy to use django tables, otherwise it will be easy anyway :wink:
I had the idea of developing when I was developing a Dashboard and always had to write the tables several times in html :sleeping:
Installation
Simple djangotables can be installed with pip::
pip install djangotables
Requirements
- Python
3.6; 3.7
- Django
2.0; 2.1; 2.2
These are the officially supported python and package versions. Other versions will probably work
Usage
It's very simple to use, you just have to import djangotables.tables
on
your tables.py
file and create your subclass like below.
from djangotables import tables
class UserTable(tables.Table):
first_name = tables.TextField(label="First Name")
last_name = tables.TextField(label="Last Name")
So, in your vews.py
file, just import your table class and instantiate it
by passing the queryset
from .tables import UserTable
from django.contrib.auth.models import User
from django.shortcuts import render
def index(request):
table = UserTable( User.objects.all() )
return render( request, "index.html", {
"table": table
})
To finish, on your index.html
template file you just have to do this
<!DOCTYPE html>
<html lang="en">
<head> ... </head>
<body>
<table>
{{ table | safe }}
</table>
</body>
</html>
Okay, this is how simple you can use djangotables to improve your daily development, feel free to contribute and help me make this little library bigger
Okay
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
File details
Details for the file djangotables-0.0.3.tar.gz
.
File metadata
- Download URL: djangotables-0.0.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d61c43a1a275d911fa4ec7fb5a013d76c66c704d19cce82d2b58bbd13c063898 |
|
MD5 | a253b875eaa349a170855a87f68cf495 |
|
BLAKE2b-256 | 2295b6d7067cfa5470614d122e2cda2c06e4771e519481b10c848b25545064fe |
File details
Details for the file djangotables-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: djangotables-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a000dd9cab680a65633b2c5b2fb25551f87b2a1387340d7cc52a3232ba0b328f |
|
MD5 | ab4a485f260664f03a78ab9e36919a8c |
|
BLAKE2b-256 | 9da5e235a7a8c7eb659ec4c17d339fa936c1ffa24417b0c7837a3193f7ddd769 |