How to store a dictionary in a Django database model's field

前端 未结 9 1423
不思量自难忘°
不思量自难忘° 2020-12-03 20:31

I need to save a dictionary in a model\'s field. How do I do that?

For example I have this code:

def create_random_bill(self):
    name_chars = re.co         


        
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 21:16

    I just discovered the django-jsonfield package, which

    is a reusable Django field that allows you to store validated JSON in your model.

    Looks like a viable option to achieve what you want.

提交回复
热议问题