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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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