For your information, Django automatically creates the id field when creating the model. You don't have to create an id field in the model, but after you migrate, the model name.Available as id.
If you make it
id = models.AutoField(primary_key=True)
You can use it
class Users(models.Model):
something = models.PositiveIntergerField(unique=True, default=number)
def number(self):
num = Users.objects.count()
if num == None:
return 1
else:
return num + 1
You can do it with that.
© 2025 OneMinuteCode. All rights reserved.