[Flask] Class attribute name of "id" for primary key in database models?

Corey Boyle coreybrett at gmail.com
Mon Apr 29 11:32:12 EDT 2019


There seems to be a common practice of using "id" for the attribute
name of primary keys in database models. This has always bothered me a
little because editors will often show "id" in a different color
because it is a Python builtin. I know that it's a class attribute and
therefore not technically overloading the builtin, but it still seems
a little wrong to me. Is there some practical advantage to this
practice? Could I just use "pk" instead of "id"?


More information about the Flask mailing list