Is there any way filter via foreignObject
see my code, which I want to fix.
model Part :
class UserProfile:
blahblah
class FreeTime :
owner = models.ForeignKey(UserProfile)
fromTime=models.DateField()
toTime=models.DateField()
Now, coding part
givenTime = date(2012,11,11)
freeTimes = FreeTime.objects.filter(fromTime__lte=givenTime, toTime__gte=givenTime)
users = []
for freeTime in freeTimes:
users.append(freeTime.owner)
//todo : remove duplicated object of user
This is totally waste of code.
As you see, what I want to is, find user who is free at given time.
Any way to reduce the code?
I think this should work:
EDIT:
As @calvin Cheng says, you should FK to User: