目次
モデル
from django.db import models
class BreedofDog
(models.Model):
name = models.CharField('犬種名', max_length=128)
class DogData(models.Model):
name = models.CharField('名前', max_length=128)
owner = models.CharField('飼い主名', max_length=128)
breedofdog = models.ForeignKey(BreedofDog
, verbose_name='犬種', on_delete=models.PROTECT)
並び変え
result_list = DogData.objects.all().order_by('breedofdog__name')