Opened 14 years ago

Closed 14 years ago

Last modified 8 years ago

#326 closed enhancement (wontfix)

IPAddressField in decimal format

Reported by: Bless Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: 1.0
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


An IP address is stored in string format and allocating 15 bytes (120 bits)

But it would be possible convert that address to decimal format and store it in less bits.

>>> import socket, struct 
>>> ip = ""
>>> q = ip.split(".")
>>> n = reduce(lambda a,b: long(a)*256 + long(b), q)
>>> n
>>> socket.inet_ntoa(struct.pack('!I', n))

Change History (2)

comment:1 Changed 14 years ago by Adrian Holovaty

Resolution: wontfix
Status: newclosed

If you're concerned about using fewer bits, use PostgreSQL, which has a custom IP address column type (which Django uses). Django only uses string formats for MySQL and SQLite.

comment:2 Changed 8 years ago by Aymeric Augustin

Easy pickings: unset
UI/UX: unset

#17245 was a duplicate.

Note: See TracTickets for help on using tickets.
Back to Top