I am going to launch a large Django project at work. Key features are form processing. There will be many forms that users of the application will use. And one of the requirements is that it should be possible to edit forms in the application admin interface.
That is, it is not necessary to add / remove form fields. But it should be possible to edit the attributes of the form field. For example, change the fields that are required, and such.
Anyone have any good decisions on how to do this. I think that I may have to subclass the fields that I want to be dynamic and do something there. I think that all model fields should have "blank = True / null = True", and some how to add some meta-information in a separate model (?) About a model that announces which fields are required. And then use this information when forms are displayed and validated.
Before I start doing this, I would really like to contribute to the development of such a solution, did anyone have any ideas on how to do this?
After further research, I found out that you can make a'lot with factory functions that return a form with a given set of attributes. So the problem does not seem to be that hard to solve.
I would make a function that returns a form with the desired attributes / fields. But the part that I did not find a good solution for is how to manage this in the admin interface. I think I will make db.Model which stores information about other model fields. Where can I establish what is required and the like.
And then in the function that returns the form, go through this model and return the form with the correct attributes. But how to make this model (which should reflect other fields of models) in a good way?
source
share