Reputation: 1106
I have a "Job" object when I do
jobs=Job.objects.exclude(end_time__lte =datetime.now(), isActive=True)
or
jobs.filter( isActive=True)
isAvtive query doesn't wotk at all. What can be the problem? I use MySQL, in job table True register as 1 , Fakse Register as 0 , nad the Job model :
class Job(models.Model):
title=models.CharField(max_length=40)
genre=models.ManyToManyField(JobGenre)
location=models.TextField()
start_time=models.DateTimeField()
end_time=models.DateTimeField()
description=models.TextField()
reward=models.TextField(null=True)
isActive=models.BooleanField(default=True)
def __unicode__(self):
return self.title
class meta:
ordering=['-end_time','creator']
Upvotes: 0
Views: 195
Reputation: 41950
It's not clear what you're trying to achieve. If you want all records where isActive
is TRUE
, then...
jobs = Job.objects.filter(isActive=True)
...should work. If you want to exclude all records where isActive
is TRUE
, then you want...
jobs = Job.objects.filter(isActive=False)
One of these two should return some results, unless your DB table has no data in it.
Upvotes: 2