0π
I donβt think its possible to do currently, I think the best you can do is to do it is to iterate over the models.
for model in ModelA.objects.all():
for val in model_a.colA:
val = val + 1
model.save()
You can do this as an atomic transaction as well if you wish.. Although it may be worth considering if this field really should be an array field.
π€Sayse
0π
You can try using the django-bulk-update package. Although Iβm not sure whether it can handle ArrayField
π€ilse2005
- [Django]-DRF: Always apply default permission class
- [Django]-ImportError: No module named remote
- [Django]-Django+MySQL β "Authentication plugin 'caching_sha2_password' cannot be loaded"
- [Django]-How to stream a file in a request?
-2π
Why not do a database migration? Djangoβs database migration system should allow you to do this easily, I believe.
π€ubadub
- [Django]-Django Foreign Keys Breaking with Multi-Table Inheritance
- [Django]-AttributeError: 'CharField' object has no attribute 'model'
Source:stackexchange.com