Quantcast
Channel: merge querysets in django - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by linuxhackerman for merge querysets in django

For a perhaps more semantically clear solution:def get_all_players(self): return (self.players1.all() | self.players2.all()).distinct()

View Article


Answer by Tadeck for merge querysets in django

This should do the trick:# On the top of the file:from django.db.models import Q# Game instance method:def get_all_players(self): return Player.objects.filter(Q(games1__pk=self.pk) |...

View Article

merge querysets in django

I have in models.py:class Game(models.Model): players1 = models.ManyToManyField(Player, related_name='games1') players2 = models.ManyToManyField(Player, related_name='games2') def...

View Article
Browsing latest articles
Browse All 3 View Live




<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>