class MyModel(models.Model):
id = models.IntegerField(primary_key=True)
or
class MyModel(models.Model):
id_ = models.IntegerField(primary_key=True)
According to pep8, single_trailing_underscore_ should be used to avoid conflicts with the Python keyword, but a column named id_ would look ugly and possibly lead to confusion with someone not familiar with python at the database level.
Django docs uses the id column name:
https://docs.djangoproject.com/en/1.11/ref/models/fields/#uuidfield .
Can this field be called "id"?
source
share