Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting default value for integer field in django models

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?

like image 313
Sandip Agarwal Avatar asked Aug 09 '11 06:08

Sandip Agarwal


1 Answers

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

models.PositiveSmallIntegerField(default=0)
like image 165
plaes Avatar answered Sep 17 '22 02:09

plaes