In my database there are tables for ArtworkImage, Artwork, and Artist.
Every ArtworkImage belongs to an Artwork, and every Artwork belongs to
an Artist.
class Artist(models.Model):
directory = models.CharField(max_length=128) # this is a lowercase
version of the artist's name
...
class Artwork(models.Model):
artist = models.ForeignKey(Artist)
...
class ArtworkImage(models.Model):
artwork = models.ForeignKey(Artwork)
I spent yesterday trying unsuccessfully to write a query that would
return a set of ArtworkImages associated with a particular
Artist.directory. The docs about reverse foreign-key lookups seem to
indicate that this is possible:
artist = Artist.objects.get(directory='smith')
artst_image = artist.artworkimage_set.all()[0] # I just want one
I've clearly misunderstood something because this throws
> 'Artist' object has no attribute 'artworkimage_set'
Thanks for the help.
Franklin
--
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.com
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.