django-queryset
In Django, what is the most efficient way to check for an empty query set?
I\'ve heard suggestions to use the following: if qs.exists(): ... if qs.count(): ...开发者_如何学编程[详细]
2023-03-23 13:47 分类:问答Fulltext indexes vs pattern_ops indexes
I am using django, and all of my queries are created by django, so i have no handwritten queries... I have a table of BillRecords, which has a field subscriberno . In my django filters, i use a filte[详细]
2023-03-23 02:56 分类:问答Django queryset to match all related objects
Let\'s say I have a ForeignKey from Coconut to Swallow (ie, a swallow has carried many coconuts, but each coconut has been carried by only one swallow).Now let\'s say that I have a ForeignKey from hus[详细]
2023-03-21 22:50 分类:问答Optimizing Django queries
I have a page where users can see the comments list for a specific product. In the view I get the list with:[详细]
2023-03-20 23:34 分类:问答How to aggregate computed field with django ORM? (without raw SQL)
I\'m trying to find the cumulated duration of some events, \'start\' and \'end\' field are both django.db.models.DateTimeField fields.[详细]
2023-03-19 14:15 分类:问答Toggle boolean fields from a Queryset using F objects
I\'ve tried these queries with these results: queryset.update(done=not F(\'boolean\')) {\'time\': \'0.001\', \'sql\': u\'UPDATE \"todo_item\" SET \"done\" = True\'}[详细]
2023-03-19 01:00 分类:问答How to filter a django queryset based on the number of many-to-many relationships?
I have the following situ开发者_开发知识库ation: A person can belong to multiple organizations and an organization can have multiple members (Persons)[详细]
2023-03-18 11:55 分类:问答Django query for ManyToManyField
class UserProfile(models.Model): user = models.ForeignKey(User, unique = True, related_name = \'user\')[详细]
2023-03-18 04:23 分类:问答Django filtering a queryset -
What I am trying to do is to write a query set that filters out unique parent/name combinations.I\'m only interested in the first occurance of a unique parent name.[详细]
2023-03-17 17:17 分类:问答django how to get the 0th item from a possibly empty list
I have a simple blog app with the model \"Post\". If I delete all the entries in the Post model I get an error when I try reference the first item in the post list ordered by date, which I did like th[详细]
2023-03-17 05:37 分类:问答