Django Dynamic Table
-
The djdynatable library provides a convenient and flexible way to work with dynamic tables in your Django application. It allows you to create tables programmatically, add columns, modify existing tables, and perform other operations without the need for complex migrations or model definitions. However you can create tables on-the-fly based on user input or other dynamic factors.
-
With added django-tenants you can add custom schema whereas your tables will be created in that schemas rather than public schemas in your postgres db .
refer : https://docs.djangoproject.com/en/5.0/ref/schema-editor/
Authors
Prerequisite
- python
- Django
- Django-rest-framework
1. Installation
1.1 Initial setup
- Install djdynatable using pip
pip install djdynatable
- In your django application , browse to installed_apps section in settings.py and add this ,
INSTALLED_APPS = [
'djdynatable',
'rest_framework'
]
- Now add urls in urls.py
urlpatterns = [
path('', include('djdynatable.urls'))
]
1.2 Migrations
- once all the steps done from the above section 1.1 .
- now we can apply the migrations for the database using ,
- python manage.py makemigrations
- python manage.py migrate
2. Setup (without django-tenants)
-
by default the public schema will be selected
-
navigate to api/table/
-
To set up a new dynamic table, send a POST request to api/table/ with the following body data:
{
"tblname":"customer_details",
"columns":[
{
"colname":"username",
"coltype":"string"
},
{
"colname":"phone_number",
"coltype":"number"
}
]
}
-
now in your pgadmin under public schema , check that the new table will be created dynamically with 2 columns as id, username , phone_number , without any migrations
-
with rest of the api's your can dynamically add , drop , modify columns and rows as per your need .
2.1 . Setup (with django-tenants)
-
make sure you completed the basic setup instructions mentioned in the django-tenants documenatation , for more info check here
-
now navigate to api/table
-
now the table creation post api need to called with same body data , the new schema will be created in your postgres db in that the dynamic tables will be created
for more information check the api documentation
Metadata
Release files for djdynatable 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djdynatable-1.0.4.tar.gz | 13.3 kB | Without provenance | Details for djdynatable-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djdynatable-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for djdynatable-1.0.4-py3-none-any.whl |
Total release size: 28.5 kB
Release files / djdynatable-1.0.4.tar.gz
| Download URL | djdynatable-1.0.4.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
403e00b624799392e8e41baa8bcdba64556fe0e88acc8aa442448152fa4908b1
|
|
BLAKE2b-256 checksum How to use checksums |
c08f3d05704ca7522fe5b39b40309b88c1ad971434ea71c3ff63358ec022fc2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / djdynatable-1.0.4-py3-none-any.whl
| Download URL | djdynatable-1.0.4-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd1ea66f6cba794d182661e2ad8e14cd22a4c4ccf083a9fc09ef8734bfae1b77
|
|
BLAKE2b-256 checksum How to use checksums |
07d1d259d696fdc240d4eb6d61311e016e3468583ce022179d2766363575dd23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for djdynatable 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.