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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3awheWS7AK%2BBfjGwW%3DkyoeJOTqGfr0gJ01rHbO%3Ds4PnJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to