Newbie question about _set
class People(models.Model):
GenderChoice=(
(u'M', u'Male'),
(u'F', u'Female'),
)
PositionChoice=(
(u'S',u'Student'),
(u'A',u'Admin'),
)
Schoolnum=models.IntegerField(primary_key=True)
Gender=models.CharField(max_length=100,choices=GenderChoice)
Name=models.CharField(max_length=100)
Birthday=models.DateField()
Age=models.IntegerField()
Email=models.EmailField(blank=True)
Password=models.CharField(max_length=100)
Position=models.CharField(max_length=100,choices=PositionChoice)
CellPhoneNumber=models.IntegerField(max_length=11)
HeadImage=models.ImageField(upload_to='c:\website\photos')
def __unicode__(self):
return self.Name
def meta(self):
ordering=['Name']
abstract=True
class Comment(models.Model):
CommentSchoolNum=models.ForeignKey('People')
CommentWord=models.TextField()
CommentTime=models.DateField()
def __unicode__(self):
return self.CommentWord
why I cannot use such sentense:
s=People.objects.filter(Position='A')
s.comment_set.all()
The django says that the queryset does not have the attribution
comment_set.Why?
--
吾血之血啊
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home