How to create dynamic models in django

3 views
Skip to first unread message

Prashanth Patelc

unread,
Mar 10, 2022, 12:39:02 PM3/10/22
to eav-django
Hi ,
Thanks in Advance

I am using django restframework i want to create one api like dynamic models(tabel creation with fields)

what im looking for creating dynamic models whenever user want new table with cutom fields he need to create own we are giving all types selection boxes in fron-end , table name only he's entering..


1) don't store into models.py (production issues reasons, all are know issues)
2) store into database , i am using PostgreSQL
3) that api will hit in fron-end
eg of tables creation:
front-end , he will give choice fields 
key                                value

table_name                  Users

fields_name                email
type                              EmailField
length                         40
unique                        True 

fields_name                password
type                                character
length                         20
unique                        True

2nd table

table_name                  Login

user_login         ForignKey(Users,on_delete=models.CASCADE,,related_name=''loginuser)

fields_name                logintime
type                              TimeField
length                         40
unique                        True 

fields_name                name
type                              character
length                         20
unique                        True


schema need to define any diffrent types but i need store in postgresql(table name with fields)
,,,,,,,many fields


Any example please share me (code)







Reply all
Reply to author
Forward
0 new messages