This one is interesting. I was also looking for the solution of the same problem.
If I understand correctly, the problem with forms is - User can choose the name of the field and the type of the fields e.g. IntegerField(). FloatField(), etc. Kind of a form that is generated using a form :P More like a Form Builder App which will help users create DYNAMIC FORMS. Am I correct? We could create a form for that with 2 inputs elements. One input to enter the name of the field. Second would be a dropdown (select html element) with the type of the model fields that django models.Model has. We can also add select dropdown for constraints. Store the values of these two in a JSONField(). This part is simple and possible. The real challenge is - *How to turn them into models and store the actual data?* *Solution 1* That is also simple. We could create a default string that resembles the source code of a model class of a django model. and create the code for it by writing the if clauses for diff fields of the models and create a string for the same. Then write this string to a .py file. e.g. "class BaseModel(models.Model): created = models.DateTimeField(auto_now=False, auto_now_add=True,) updated = models.DateTimeField(auto_now=True, auto_now_add=False,)" The Problem with this approach is app will end up with lots of .py files that has diff models. Making migrations and Migrating will also be a pain point. Making any migrations will require stopping and restarting the server (nginx+gunicorn), that is not possible in a production environment. Will have to restart the server for every new form created and migrated. *Not a good idea to do this.* *Solution 2* As each form/model would have a separate schema, using a JSONField() makes sense here. As we are storing forms in JSONField(), store the data also in the JSONField(). This wont require making any models/migrations and migrating the database. Also server restarts are not required at all. This is more feasible solution and will be easier approach than the earlier one. However, making the forms populate/reder dynamically from the stored json field and validating them dynamically according to their schema *NEEDS SOME R&D*. Give it a try and share the results with me. I hope it was worth your time :) Regards, Chetan Ganji +91-900-483-4183 ganji.che...@gmail.com http://ryucoder.in On Mon, May 13, 2019 at 4:38 PM Devender Kumar <dev1en...@gmail.com> wrote: > Thank you for your suggestion > I am using PostgreSQL > You have successfully saved the layout but I am talking about the dynamics > forms fields which will be used for form submission how you are looking to > store the values of 1000's of records entered after that in those fields. > that's why I was looking for more efficient way (as I know this solution > already ignore the fact that storing the json of record values too) as it > might decrease the efficiency of the system. > > On Monday, May 13, 2019 at 3:58:47 PM UTC+5:30, Devender Kumar wrote: >> >> Hi, >> I want to make a web app in which user has rights to configure his >> layout.Means each user can configure his layout according to his choice and >> work >> Like how many fields can his form have how many field he want to see in >> table view of individual record view . configure theme color of his own >> choice . >> all these type of settings he can do for his own use. >> Can any one help me with this type of architecture. >> Thank you >> Devender >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/ec432f98-e6ce-4849-9d8d-46237f451cda%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/ec432f98-e6ce-4849-9d8d-46237f451cda%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMKMUjspS2BqJpAyDMyOVHrQK334vNyPopo4wAGCyGMEBT%3DDEw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.