Skip to content

Instantly share code, notes, and snippets.

View ivardu's full-sized avatar
🎯
Focusing

Ravi Kumar ivardu

🎯
Focusing
View GitHub Profile
@tashirka1
tashirka1 / admin.py
Created December 10, 2018 16:39 — forked from gauravvjn/admin.py
Use JSONField properties in Django admin filter Raw
# You have a model something like this
from django.contrib.postgres.fields import JSONField
class MyModel(models.Model):
jsonfield = JSONField() # {"name": "Gaurav", "age": "25", "address": {"country": "India", "city": "Jaipur"}}
# few more fields...
# And in admin you want to create filter for jsonfield properties/keys
# for e.g. in above case we want to show filter for age and country