Top "Django-queryset" questions

Django querysets are the primary abstraction for retrieving objects from Django's ORM system

How to perform OR condition in django queryset?

I want to write a Django query equivalent to this SQL query: SELECT * from user where income >= 5000 or income …

python sql django django-queryset django-orm
Checking for empty queryset in Django

What is the recommended idiom for checking whether a query returned any results? Example: orgs = Organisation.objects.filter(name__iexact = …

django django-queryset
How to do a less than or equal to filter in Django queryset?

I am attempting to filter users by a custom field in each users profile called profile. This field is called …

python django django-queryset
Django values_list vs values

In Django, what's the difference between the following two: Article.objects.values_list('comment_id', flat=True).distinct() vs Article.…

django django-models django-queryset django-orm
How to remove all of the data in a table using Django

I have two questions: How do I delete a table in Django? How do I remove all the data in …

python django django-queryset
Select DISTINCT individual columns in django?

I'm curious if there's any way to do a query in Django that's not a "SELECT * FROM..." underneath. I'm trying …

django django-models distinct django-queryset django-orm
Getting a count of objects in a queryset in django

How can I add a field for the count of objects in a database. I have the following models: class …

django django-models django-queryset
Get the latest record with filter in Django

I am trying to get the latest Django model object but cannot seem to succeed. Neither of these are working: …

python django django-models django-queryset
Select distinct values from a table field

I'm struggling getting my head around the Django's ORM. What I want to do is get a list of distinct …

django django-queryset django-orm query-performance
Django - filtering on foreign key properties

I'm trying to filter a table in Django based on the value of a particular field of a ForeignKey. For …

django django-models django-queryset