ネストされたツリー分類を使用してモデルを構築しています。ボキャブラリEntityは抽象基本クラスから継承されTreeVocabularyます。SpecialEntityから継承するクラスもありEntityます。には、いくつSpecialEntityかの追加フィールドがあるはずです。
Entityどちらもツリーである必要がありSpecialEntity、そのために mptt http://django-mptt.github.com/django-mptt/を使用します。にEntity子を持つレコードがあるはずですSpecialEntity(これらの子は のルート要素ですSpecialEntity)。
これは私がこれを想像する方法です:
class Vocabulary(models.Model):
name= models.CharField(max_length=300)
order= models.IntegerField(default=100)
class Meta:
abstract= True
class SpecialType(Vocabulary):
class TreeVocabulary(MPTTModel):
parent= TreeForeignKey('self', null=True, blank=True,
related_name='children', limit_choices_to=Q(parent__isnull=True))
class MPTTMeta:
order_insertion_by= ('name',)
class Meta:
abstract= True
class Entity(TreeVocabulary):
class SpecialEntity(Entity):
code= models.CharField(max_length=50)
type= models.ForeignKey(SpecialType)
class Meta:
ordering= ('code',)
さて、問題は、何らかの理由でSpecialEntitymptt をエスケープすることです: 含まれていsqlallないプレーンなテーブルを表示parent_idします。に存在しますがEntity、 から直接継承しTreeVocabularyます。
django-mptt のバグですか? それともデザインが悪いのでしょうか?私は私のためにそれを設計するように頼んでいるのではなく、正しい方向に向けることを求めています
前もって感謝します!