django-types icon indicating copy to clipboard operation
django-types copied to clipboard

Why declare AutoField when you can just type the id?

Open razorman8669 opened this issue 4 years ago • 1 comments

in the readme, in order to get the id field to be recognized, it's recommended to declare the AutoField explicitly like so:

# before
class Post(models.Model):
    ...

# after
class Post(models.Model):
    id = models.AutoField(primary_key=True)

But why not just assign a type to the id field like so:

# after
class Post(models.Model):
    id: int

the later avoids any unnecessary migrations from being created during makemigrations after modifying the models.

razorman8669 avatar Nov 11 '21 18:11 razorman8669

The README has been updated, this can probably be closed

guido-travelperk avatar Dec 09 '21 19:12 guido-travelperk