Django Postgresql jsonfield queryset

33 views Asked by At
p = Profile(name="Tanner", data={'daily__email': '[email protected]', 'weekly__email': True})
p.save()

Profile model has jsonfield.

Profile.objects.filter(data__daily__email='[email protected]')
Profile.objects.filter(data__daily__email__startswith='a')

how can i find Tanner on queryset?..

how can i find Tanner on queryset?

1

There are 1 answers

0
Tarquinius On
Profile.objects.get(name="Tanner")

Get lookups error when it finds multiple entries with specified search criteria and will error when it does not find one matching entry.

Profile.objects.filter(name="Tanner")

As your quesiton implies you are already familiar with filter lookups