python-3.xdjangodjango-modelswagtailwagtail-streamfield

Django Wagtail dynamically create form without new model


How would I allow my primary user to dynamically create forms they can issue to their end clients. Each of my primary users has their own unique information they would like to collect that I do not know before hand. I would like to avoid creating new models in code for their dynamic needs and then having to migrate the models.

I came across this which had an interesting response but it starts with disclaimer

The flexibility of Python and Django allow developers to dynamically create models to store and access data using Django’s ORM. But you need to be careful if you go down this road, especially if your models are set to change at runtime. This documentation will cover a number of things to consider when making use of runtime dynamic models.

Which leads me to believe a lot can go wrong.

However because I'm using wagtail I believe there is probably a way to use StructBlocks & StreamFields to accomplish it.

Any guidance would be helpful.


Solution

  • Wagtail provides a form builder module for this purpose.