A model for our JSON
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 ...
Get Django Project Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.