Skip to content

Instantly share code, notes, and snippets.

View DmytroLitvinov's full-sized avatar
🇺🇦

Dmytro Litvinov DmytroLitvinov

🇺🇦
View GitHub Profile
@DmytroLitvinov
DmytroLitvinov / update.py
Last active March 28, 2021 06:46 — forked from bmispelon/update.py
[Django ORM] Updating a JSONField based on the value of another field
"""
How to update JSONField based on the value of another field.
For example:
class MyModel(models.Model):
name = models.CharField(...)
data = models.JSONField()
How to update the MyModel table to store the `name` field inside the `data`