How to store a dictionary in a Django database model's field
问题 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.compile("[a-zA-Z0-9 -_]") bill_name = "".join(random.choice(name_chars for x in range(10))) rand_products = random.randint(1,100) for x in rand_products: bill_products = new_bill = Bill.new(name=bill_name, date=datetime.date, products=bill_products) new_bill.save() What do I write for "bill_products=" so it saves some random products, from my Product