django-orm
Extract latest entry from a model in Django
Let\'s say I have th开发者_开发百科e following Django model: class Info(models.Model): instrument = models.ForeignKey(\'Instrument\')[详细]
2023-03-08 10:58 分类:问答Django: Force table creation order on syncdb
I have a Profile model that is used to define a profile for a User from the auth application. Also, I have a signal that will create an empty profile each time a user is created.[详细]
2023-03-07 17:39 分类:问答How do I calculate a set of answers' scores in one query?
I am writing a webapp similar to Stackoverflow. How can I query Questions and annotate each question with its score, which is simply how many upvotes it\'s has minus how many downvotes it\'s had.[详细]
2023-03-07 15:25 分类:问答Django order items by two fields, but ignoring them if they're zero
I have the following model (greatly simplified for the purposes of this question): class Product(models.Model):[详细]
2023-03-06 08:58 分类:问答routing a manytomany table to a non-default db in django
I\'m using django\'s multi-db support via database routers to partition certain models to 1 db, and others into another.(Note that whether I \"should\" be doing that is irrelevant to my question.)I ha[详细]
2023-03-06 01:40 分类:问答Changing South Migration Directory
How do you change the location where South looks for an app\'s migrations? By default, South assumes an app\'s migrations are in /migrations. However, I\'ve migrated the model of a third-party packag[详细]
2023-03-05 23:41 分类:问答Speeding Up the Django Admin Delete Page
How would you speed up the Django Admin record deletion action/page? I have a model B with a foreign key constraint to model A. For every record in A, there are about 10k records in B bound to A. So[详细]
2023-03-04 12:11 分类:问答Django order_by causes LEFT JOIN
Can anyone tell me why when I add the order_by() the query that gets output changes from a INNER JOIN to an LEFT OUTER JOIN?[详细]
2023-03-04 07:03 分类:问答Django Models Group By
I have this simple SQL query - SELECT pid, COUNT(*) AS docs FROM xml_table WHERE suid=\'2\' GROUP BY pid;开发者_如何学C[详细]
2023-03-03 22:32 分类:问答Django: how to prevent parent object to be deleted when deleting its child object
Class A(models.Model): name = models.CharField() Class B(A): extra_info = models.CharField() When I delete an B object, its parent obje开发者_如何学Pythonct A also gets deleted, how to solve this h[详细]
2023-03-01 05:03 分类:问答