Hello all,
Accessing the foreign key object is simple using _set
lets say I have a models like:
class Profile(models.Model):
"""
extended auth user profile
"""
user = models.OneToOneField(User)
emp_id = models.CharField(max_length=10)
phone_number = models.CharField(max_length=15)
def __unicode__(self):
return "%s" % self.user
class Complaint(models.Model):
"""
users complaints
"""
user = models.ForeignKey(Profile)
complaint = models.TextField()
I can access Profile's objects as
user_profile = Profile.objects.get(user=USER_INSTANT)
and then
user_profile.complaint_set.values()
but can I access it reversely ??
I mean
complaint.profile_set.values() like this
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.