Relative Content

Tag Archive for djangoorm

Django ORM – .exclude Q vs exclude(ids_in=ids) with Subquery, annotate

Django Queryset exclude() not working as expected with Q expressions I’m trying to exclude some Project objects from my queryset using two different methods: one based on IDs and the other using a Q expression on annotated data. However, I’m getting different results from each approach, and I can’t figure out why. The version with […]

Ordered Many-To-Many Custom Through Table, Now Field Has Duplicates

As the title indicates, when I try to order by my custom through table, the field now shows duplicates. It seems to be doing a left outer join, displaying all fields on both sides instead of showing only unique values, and distinct() seems to do nothing here. I’m using sqlite3 and distinct(‘field-name’) isn’t supported with sqlite3. Here’s a dumbed-down summary of my code, showing only relevant fields: