As I have mentioned earlier, one of the biggest benefits of using JSON as the definition format for our forms is that it uses just simple text data to encode the definition of complex objects. While some databases such as PostgreSQL have a column type for JSON, others do not. However, because we are dealing with simple text data, we don't need one! We can store our JSON data in a simple TextField
and then encode and decode the data to and from a Python dictionary whenever required. In fact, there are many people in the Django community who have already dealt with this problem and open sourced their solutions for us to use.
One such package that I have used in the past is django-jsonfield
. You can find it at https://github.com/bradjasper/django-jsonfield, and we will be using it in our project. First, install the required package by typing the following command in your command line. Make sure to have the virtual environment activated first so that it is installed in the...