jsonfield: Problems withs PostGres 9.3, JSON Field and Query Distinct
As mentionned in #47, using “.distinct()”, which is used by the admin panel creating users but also in several other cases in django processes, triggers the same bug as #47 describes.
A workaround has been found by @mkhattab :
The work around for this in the Django admin is to subclass QuerySet and Manager and override the distinct method [to remove the JSON fields from it].
What would be the definite fix ?
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 20 (1 by maintainers)
Commits related to this issue
- Point jsonfield to dev version that works with Postgresql 9.3. After updating to Postgresql 9.3, I was getting failing tests because the jsonfield package was trying to use the native Postgres 'json'... — committed to churchlab/millstone by glebkuznetsov 11 years ago
- Removed native JSON datatype support from PostgreSQL See https://github.com/bradjasper/django-jsonfield/issues/57 for more information — committed to rpkilby/jsonfield by bradjasper 10 years ago
- Requirements bump Leaving out jsonfield 1.03 until I can wrap my head around PostgreSQL issue: https://github.com/bradjasper/django-jsonfield/issues/57 — committed to tulsawebdevs/django-multi-gtfs by jwhitlock 9 years ago
Solved my case.
Hope, this helps to somebody
I had this issue popping up in Admin list views for models that contained JSON columns (even though I wasn’t showing those field in the view). Interestingly enough, when the view is called, it doesn’t actually call the
distinctmethod on theManager. My workaround was to subclass the manager, and override theget_query_setmethod as follows: