Please take a look at these models:
class Album(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now) class Photo(models.Model): album = models.ForeignKey(Album, default=3) image = models.ImageField(upload_to=get_upload_file_name) caption = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now)
How to get a set of photos for a specific album ??? And how to get an album from the photo itself?
I tried this:
# To get the set of photos from the user (tika) album: >>>t = User.objects.get(username='tika') >>>t_album = Album.objects.get(user=t) >>>t_album <Album: tika_album> >>>t_album.image_set.all() AttributeError: 'Album' Object has no attribute 'image_set'
Please guide me in the right direction. Thanks.
source share