Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uhttred/djangotables
Djangotables is a simple library for generating html tables with Django Framework using model data like django forms.
https://github.com/uhttred/djangotables
damgo-tables django django-forms django-framework djangotables html library python script
Last synced: 6 days ago
JSON representation
Djangotables is a simple library for generating html tables with Django Framework using model data like django forms.
- Host: GitHub
- URL: https://github.com/uhttred/djangotables
- Owner: uhttred
- License: mit
- Created: 2019-09-26T11:06:19.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-26T20:34:36.000Z (about 5 years ago)
- Last Synced: 2024-10-29T03:06:00.366Z (18 days ago)
- Topics: damgo-tables, django, django-forms, django-framework, djangotables, html, library, python, script
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
djangotables
===============Djangotables is a simple library for generating html
tables with [Django Framework](https://www.djangoproject.com/) 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 workUsage
----------------It's very simple to use, you just have to import ``djangotables.tables`` on
your ``tables.py`` file and create your subclass like below.```python
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```python
from .tables import UserTable
from django.contrib.auth.models import Userfrom 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
```html
...
{{ table | safe }}
```
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