I have two models, Position and Player, for a baseball site. Positions are named pitcher, catcher, first base, second base, third base, etc.
class Position(models.Model):
name = models.CharField(max_length=100)
slug = models.SlugField()
class Player(models.Model):
name = models.CharField(max_length=300)
slug = models.SlugField()
position = models.ForeignKey(Position)
Is there a way to make one query to return players in a specific order? For example, I'd like to do something like:
Player.objects.all().order_by(position=('first base', 'second base', 'third base', 'pitcher', 'catcher',))
This will return all players sorting them by the position field in the specified order of first base, second base, third base, pitcher, catcher, etc.