1👍
You can use related name:
class ArtistArtwork(models.Model):
...
artwork = models.ForeignKey('gql_service.Artwork', related_name='artwork_artistartwork')
And then in the ArtworkService
class ArtworkInfo(object):
@property
def main_artist(self):
artist = self.artwork.objects.filter(artwork_artistartwork__is_main_artist=True).first()
return artist
0👍
Did it as:
@property
def main_artist(self):
return self.artwork.artists.filter(
artistartwork__is_main_artist=True
).first()
- [Answered ]-Is there any acceptable way to chop/recombine Django querysets without using the API?
- [Answered ]-Django: performing a SQL match all in Django
- [Answered ]-Django CreateView modelform
- [Answered ]-How to use curent date in image path django
Source:stackexchange.com