[Django]-Django IntegerField returning long

4👍

this is probably a side effect of the underlying dbapi handler, which returns long for most everything:

>>> import MySQLdb
>>> db=MySQLdb.connect(db="test")
>>> c = db.cursor()
>>> c.execute("Select 1")
1L

The difference for most uses is cosmetic. There are subtle differences from one driver to another, for instance sqlite3 does not return long for this same query:

>>> import sqlite3
>>> db = sqlite3.connect(":memory:")
>>> c = db.cursor()
>>> c.execute("Select 1")
<sqlite3.Cursor object at 0x7f2c425ae9d0>
>>> c.execute("Select 1").fetchone()
(1,)

Leave a comment