Django newb. I
haven't yet read everything (I admit it) but I'm hoping someone can help me out
with a quick answer.
Assuming the
following model:
class
Patient(models.Model):
study_id = models.CharField(maxlength=10)
usubjid = models.CharField(maxlength=8, unique=True, primary_key=True, db_column='usubjid')
sex = models.CharField(maxlength=1,blank=True,null=True)
birth_date = models.DateField(null=True)
screenfail = models.BooleanField(null=True)
def __repr__(self):
return "%s:%s" %(self.study_id, self.usubjid)
study_id = models.CharField(maxlength=10)
usubjid = models.CharField(maxlength=8, unique=True, primary_key=True, db_column='usubjid')
sex = models.CharField(maxlength=1,blank=True,null=True)
birth_date = models.DateField(null=True)
screenfail = models.BooleanField(null=True)
def __repr__(self):
return "%s:%s" %(self.study_id, self.usubjid)
class
Comment(models.Model):
usubjid = models.ForeignKey(Patient, db_column='usubjid')
comment_seq = models.SmallIntegerField()
form_number = models.SmallIntegerField(null=True)
visit_id = models.SmallIntegerField(null=True)
violation = models.BooleanField()
text = models.TextField(null=True)
review_status = models.SmallIntegerField(null=True)
usubjid = models.ForeignKey(Patient, db_column='usubjid')
comment_seq = models.SmallIntegerField()
form_number = models.SmallIntegerField(null=True)
visit_id = models.SmallIntegerField(null=True)
violation = models.BooleanField()
text = models.TextField(null=True)
review_status = models.SmallIntegerField(null=True)
I'm looking for
django/python syntax to retrieve all the comments that belong to a particular
study_id (which is an attribute of Patient). In SQL, this'd
be:
SELECT <Comment fields>
FROM Patient JOIN Comment on Patient.usubjid =
Comment.usubjid
WHERE Patient.study_id = 'CP-AI-005'
I'm just not sure
what django call would yield that. I've tried a few variations on filter() but
haven't hit the right solution and have failed, so far, to actually go and read
the source code. (Like everyone else, I'm in a hurry.)
Thanks for your
time.
J
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---