What is the best way to store an array of integers in a django database?
+3
A:
CommaSeparatedIntegerField comes to mind instantly. It is implemented as VARCHAR
on most database backends. To be sure though, you may want to skim through django/db/backends/*
.
ayaz
2009-09-15 19:56:38
That basically means that I have to convert the string back into integers myself?
Christian
2009-09-15 22:02:08
+1
A:
See this answer for a description of a possible alternative version of CommaSeparatedIntegerField that would do more of the work for you (converting from list to string and back). Maybe you could check in with that guy about whether he wrote it already :-)
Carl Meyer
2009-09-16 13:13:36