次のような django モデルがいくつかあります。
from django.contrib.sites.models import Site
class Photo(models.Model):
title = models.CharField(max_length=100)
site = models.ForeignKey(Site)
file = models.ImageField(upload_to=get_site_profile_path)
def __unicode__(self):
return self.title
class Gallery(models.Model):
name = models.CharField(max_length=40)
site = models.ForeignKey(Site)
photos = models.ManyToManyField(Photo, limit_choices_to = {'site':name} )
def __unicode__(self):
return self.name
ギャラリー モデルの作業を行うために、あらゆる種類の楽しみを持っています。limit_choices_to
このギャラリーと同じサイトに属する写真の選択肢のみを管理者に表示してもらいたいです。これは可能ですか?