I have two tables as shown below.
class AlertTable(models.Model):
id = models.AutoField(primary_key=True)
alarm_text = models.CharField(max_length=800,blank=False,null=False)
event_type = models.SmallIntegerField(blank=False,null=False)
created = models.DateTimeField()
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(
self.id)
class PendingAlertsTable(models.Model):
id = models.AutoField(primary_key=True)
alerttable = models.ForeignKey(AlertTable)
created = models.DateTimeField()
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(
self.id)
Idea is PendingAlertsTable holds reference to alerts that have not
been acknowledged. And AlertTable holds all the alerts.
So I want to construct query such that I can get all entries from
AlertTable that are Pending.
So I constructed query like this:
inner_qs=PendingAlertsTable.objects.all()
all_pending_events = AlertTable.objects.filter(pk__in=inner_qs)
That doesn't give me query set in all_pending_event of expected
entries. What is the correct way to construct the __in query in this
case?
-Subodh