Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store year in Django

Tags:

mysql

django

What would be the best way to store year (YYYY) in a django model? I'm using a mysql backend.

start_year = models.SmallIntegerField(blank=True, null=True) 

??

like image 693
David542 Avatar asked Apr 29 '13 20:04

David542


1 Answers

On second thought, since you're storing years, make it nonnegative.

start_year = models.PositiveSmallIntegerField(blank=True, null=True)
like image 160
Chris Avatar answered Nov 03 '22 07:11

Chris