Can a field of type models.PositiveIntegerField contain a 0 value? I'm doing something like:
points = models.PositiveIntegerField()
Thanks,
I know I should try it myself, but I haven't a Django environment here.
Can a field of type models.PositiveIntegerField contain a 0 value? I'm doing something like:
points = models.PositiveIntegerField()
Thanks,
I know I should try it myself, but I haven't a Django environment here.
Yes, it can. It is debatable whether it should--there is a longstanding bug report: http://code.djangoproject.com/ticket/7609
Yes, "PositiveIntegerField" can contain "0" value.
For example, I defined the model "Point" as shown below:
# "myapp/models.py"
from django.db import models
class Point(models.Model):
points = models.PositiveIntegerField()
Then, run this command below:
python manage.py makemigrations && python manage.py migrate
Now, I opened "db.sqlite3" then as you can see, "CHECK("points" >= 0)" is set to "points" field which means "PositiveIntegerField" can contain "0" value: