-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I aledr,

thanks for your reply,


I've added the  socket.inet_ntoa to my  view.py

#view.py
from django.http import HttpResponse
import socket
from snort.models import  Iphdr


def snort(request):

    ip = Iphdr.objects.values("ip_src")
    return socket.inet_ntoa(ip)


after opening the web page I get this error bac





Request Method:         GET
Request URL:    http://192.168.1.5:8080/
Django Version:         1.3 beta 1
Exception Type:         TypeError
Exception Value:        

inet_aton() argument 1 must be string, not ValuesQuerySet

Exception Location:     /home/user/django/app/../snort/views.py in snort,
line 10
Python Executable:      /usr/bin/python
Python Version:         2.6.5
Python Path:    

['/home/crypto/django/snort',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/dist-packages',
 '/usr/lib/pymodules/python2.6',
 '/usr/lib/pymodules/python2.6/gtk-2.0',
 '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode',
 '/usr/local/lib/python2.6/dist-packages']
~


What I'm doing wrong ?

Thanks again,

Phillip



On 01/23/2011 07:18 PM, aledr wrote:
> I guess socket.inet_ntoa is enough for what you need.
> 
> On Sun, Jan 23, 2011 at 7:06 AM, Phillip Bailey <phil...@bailey.st> wrote:
> 
> 
> 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
>>
- --
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.
>>
>>
> --
> [ ]'s
> Aledr - Alexandre
> "OpenSource Solutions for SmallBusiness Problems"

- -- 
Snorby SSD: The IDS (Intrusion Detection System) Linux distribution
http://bailey.st/blog/snorby-spsa/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJNPK10AAoJENNBJKHbaDgTKN0IAL7YlR/rmtcrj9GDbTCUElu4
81t+0Y8let5XgnvYGVjbaUyPP+BwxhoWpN8f6PqFfohPbj+Xt9EuSdJIV9Wr84Bi
NLhWtQyw/ioFZaDH1b50smEfR1qqIsQRd+wfbor21cwe5YhjorZ9FuPoH1HBFFPp
4kct+b0vMuGb0OjlWRosVAe/p3mzbNbn8glVhqaBthAl6GmAOrBuEmRqdB6jgN2s
/fLNGKi08YdlbHn5hvnmXTONiFQf5aA40ZpKlTmCWHJUiVINfuUw7FE5E/ZuYve2
l7Vs2BIIKy3X4oRFZbeQXV/yVyOKygIwdmzJZ+iBLL4zdST8YA3Zj/8Q73pX434=
=6lwe
-----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.

Reply via email to