-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Dear All, I've started playing around with Django in the last few days, and I'm enjoying the speed and the power of such framework. I'm writing a small application to display and sort ip addresses stored in a Postgresql database, right now I'm stuck with 32-bit integers IP address translated to 4-octet IP address . Here's the the class of the ip address. class Iphdr(models.Model): sid = models.IntegerField(primary_key=True) cid = models.BigIntegerField(primary_key=True) ip_src = models.BigIntegerField() ip_dst = models.BigIntegerField() ip_ver = models.SmallIntegerField() ip_hlen = models.SmallIntegerField() ip_tos = models.SmallIntegerField() ip_len = models.IntegerField() ip_id = models.IntegerField() ip_flags = models.SmallIntegerField() ip_off = models.IntegerField() ip_ttl = models.SmallIntegerField() ip_proto = models.SmallIntegerField() ip_csum = models.IntegerField() class Meta: db_table = u'iphdr' As the IP addresses are stored in the database as unsigned 32-bit integers, so when I run ip = Iphdr.objects.values("ip_src") the result is in 32-bit integers, {'ip_src': 3251031814L}{'ip_src': 3251031816L}{'ip_src': 3251031816L} {'ip_src': 3251031816L}{'ip_src': 3251031814L}{'ip_src': 3251031816L} There's any elegant solution that can translate 32-bit integers to 4-octet IP address (192.168.1.88) ? Thanks in advance. Phillip -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJNO++eAAoJENNBJKHbaDgTM0cH/0/QjdPTi53tJG4YhjVpt6oj cJk6rAEHwFha//Vby4lH2sT+ZyKmv+UAjSVmvBCptXBOcm5LuedMmMCVeInfuliQ GeOPlQ4nvrZSbcdXirLu9Jqa+Yqj6nalGF7i0WetqvdsdrkQQdrcx1D814DSZKGq qQWpdyVEmdrRSfiOUvrYbnXDCnTwCXZdUhcpDNmD+5h9S2/uiMzP5cM2wtfMg1hO swYS9B7h/6vAd1ekOZh+ij2X4mszUfp5rQzFjCXtYnQma8pN+58UMpWwYVKj2FzA tgRaWC1Qz4hWsXRvwirqo/ZtyJMWxkOdwVaxl3iug/NCGW/yDCMa97zweYOHKCs= =W+IC -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0xDB683813.asc
Description: application/pgp-keys