Skip to main content

No project description provided

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djdynatable-1.0.4.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djdynatable-1.0.4-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file djdynatable-1.0.4.tar.gz.

File metadata

  • Download URL: djdynatable-1.0.4.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for djdynatable-1.0.4.tar.gz
Algorithm Hash digest
SHA256 403e00b624799392e8e41baa8bcdba64556fe0e88acc8aa442448152fa4908b1
MD5 4c90d63d167e6e7fe3b9d4b2d8b22b5d
BLAKE2b-256 c08f3d05704ca7522fe5b39b40309b88c1ad971434ea71c3ff63358ec022fc2e

See more details on using hashes here.

File details

Details for the file djdynatable-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: djdynatable-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for djdynatable-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dd1ea66f6cba794d182661e2ad8e14cd22a4c4ccf083a9fc09ef8734bfae1b77
MD5 571e40b26cbf67b3f3297a8b7f41ebad
BLAKE2b-256 07d1d259d696fdc240d4eb6d61311e016e3468583ce022179d2766363575dd23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page