1

I was trying to update the json field but I couldn't update it because it throw me an exception. I'm using Django 2.6

class Mymodel(models.Model):
    qty = models.IntegerField(default=0)
    name = models.CharField(max_length=255)
    description = models.CharField(max_length=500)
    meta = JSONField(default={'participants': []}, blank=True, null=True)


code.py

qs = Mymodel.objects.all()
participants = ['user_ABC', 'user_XYZ']
qs.update(qty=F('qty') + 1, meta__participants=participants)

This code throw an error: FieldDoesNotExist: Mymodel has no field named 'meta__participants'.

M Usman Wahab
  • 53
  • 1
  • 10

0 Answers0