News for hackers. Stuff that matters.
Re:12 requests per second: A realistic look at Python web fr... by Izkata on Friday February 19, 2021 @08:57AM (#26193165)
> It's not a bug, it is the same value.

Not necessarily, it can be overridden: "id" is only the default for models that haven't explicitly been given a field with the "primary_key" kwarg (common on legacy tables where the primary key column might for example be "user_id").

The alias guaranteed to be the same value is ".pk", and I'm not sure what django does if you try to create a column named "pk" that isn't the primary key.

Re:12 requests per second: A realistic look at Python web fr... by ehutch79 on Friday February 19, 2021 @09:17AM (#26193372)
If your tables don't use id, or are doing something strange, YOU wrote that code. You should know it's going to be a thing you need to deal with, because YOU did something unusual.
Re:12 requests per second: A realistic look at Python web fr... by Izkata on Friday February 19, 2021 @08:55PM (#26200702)
Note that I gave the example of "legacy" tables. On long-lasting codebases there's a high likelihood that "you" didn't write that code and aren't aware of everything Django's doing under the hood.