How to use and clause in Django
For ex:
select Date(timestamp) from userlog where (Date(timestamp) >= "2008-01-02" and Date(timestamp) <= "2009-01-02") and ipaddress != "192.168.2.211";
Django query:
userlog.objects.filter(timestamp__range=(startdate,enddate),ipaddress !="192.168.2.211")
In the above there is an error saying non-keyword arg afterkeyword arg and the error is in the above line
ipaddress is a char field,Am i constructing the query wrong if so how this should be resolved
The use of
!=is not correct in Django (or indeed, not in Python). In order to exclude all records withipaddressmatching a certain value you should use theexclude()mechanism.