Django query with list of values in where clause

Posted In: , . By CreativeSolutions


If we need to fetch data like the MySQL IN clause, we can do it by using filter function with the list of values
user_ids= [1,2,3]
Ex. User.objects.filter(id__in = user_ids)

 


import time

Then add the below code
#Finding the daylight saving time
    is_dst = time.daylight and time.localtime().tm_isdst > 0
    utc_offset = (time.altzone if is_dst else time.timezone)
#Checking for negative and positve offset values
    if(utc_offset > 0):
        utc_offset_hours = (utc_offset / 3600)
        sign = '- '
    else:
        utc_offset_hours = (-(utc_offset) / 3600)
        sign = '+ '
    utc_offset_minutes =  (utc_offset % 3600) / 60
#Converting Integer values to string before concatenating
    utc_offset = sign + str(utc_offset_hours) + '.' +str(utc_offset_minutes)
    print utc_offset