sbdchd / django-types

:doughnut: Type stubs for Django
MIT License
188 stars 62 forks source link

Why declare AutoField when you can just type the id? #71

Open razorman8669 opened 2 years ago

razorman8669 commented 2 years ago

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.

guido-travelperk commented 2 years ago

The README has been updated, this can probably be closed