# # Example models # class Object(models.Model): DIRECTION_CHOICES = ('N','E','S','W') # define other fields here class ObjectPhoto(models.Model): the_object = models.ForeignKey(Object) direction = models.CharField(choices=[(x,x) for x in DIRECTION_CHOICES], max_length=1) # Then, in views.py, do something like this photo_list = list(object.objectphoto_set.all()) photo_list.sort(key=lambda x: list(Object.DIRECTION_CHOICES).index(x.direction)) # photo_list is now sorted by direction, in the order specified in DIRECTION_CHOICES # Note: if using tuples in the choices list, the lambda function will have to # change to use the correct tuple value. For example, if it was like this: DIRECTION_CHOICES = [ ('N','North'),('E','East'),('S','South'),('W','West') ] photo_list.sort(key=lambda x: [x[0] for x in Object.DIRECTION_CHOICES].index(x.direction))