Skip to content
Advertisement

Django JSON field. ‘module’ object has no attribute ‘JSONField’

I am learning Django and was frustrated by creating a json field in a model. I was trying to create a json field in my model but got error: ‘module’ object has no attribute ‘JSONField’. Here is my class in models.py:

JavaScript

I am using django 1.9.8 and postgresql 9.2.13. I need the table created in postgresql db has a column with JSON type. How can I do that in the model class? Thank you!

Advertisement

Answer

There’s no JSONField in models. But there’s a handy jsonfield package available to use JSONField in Django models. To install the package, do:

JavaScript

Once installed, do:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement