> I give the item a Instance and use item.photo_set.all()
> , but it shows error
>
> AttributeError: 'ForeignRelatedObjectsDescriptor' object has no
> attribute 'all'
>
> I check the item has attribute of photo_set, but item.photo_set has no
> attribute of all()
>
> How to solve this?
> thanks!
>
You are trying to access photo_set on the model class, rather than an
instance of the class. You must create an instance of the class, and
then use that.
>>> s.tvepisode_set.all()
[<TVEpisode: 1x01 - Pilot>, <TVEpisode: 1x02 - Last Baby Proofing
Standing>, <TVEpisode: 1x03 - TBA>]
>>> TVSeries.tvepisode_set.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'ForeignRelatedObjectsDescriptor' object has no attribute 'all'
Cheers
Tom
--
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.
No comments:
Post a Comment