Setting default value for integer field in django models


Question

I'm trying to set a default value for the integer field in Django model using

models.PositiveSmallIntegerField(default='0')

Why isn't it working?

1
8
8/9/2011 9:48:47 AM

Accepted Answer

The default value in your example is set to string ('0'), but it should be integer. Try this instead:

models.PositiveSmallIntegerField(default=0)
23
11/2/2018 9:45:43 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon