ネストされたツリー分類を使用してモデルを構築しています。ボキャブラリ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',)
さて、問題は、何らかの理由でSpecialEntity
mptt をエスケープすることです: 含まれていsqlall
ないプレーンなテーブルを表示parent_id
します。に存在しますがEntity
、 から直接継承しTreeVocabulary
ます。
django-mptt のバグですか? それともデザインが悪いのでしょうか?私は私のためにそれを設計するように頼んでいるのではなく、正しい方向に向けることを求めています
前もって感謝します!