訪問所有的報告,我認爲馮可結合此示例代碼(source)至極休息SYNC_DB
class ItemType(meta.Model):
name = meta.CharField(maxlength=100)
description = meta.CharField(maxlength=250)
properties = meta.ManyToManyField('PropertyType',
db_table='app_propertytype_itemtypes')
class PropertyType(meta.Model):
name = meta.CharField(maxlength=100)
itemtypes = meta.ManyToManyField(ItemType)
與this snippet
class ManyToManyField_NoSyncdb(models.ManyToManyField):
def __init__(self, *args, **kwargs):
super(ManyToManyField_NoSyncdb, self).__init__(*args, **kwargs)
self.creates_table = False
獲得像
class ItemType(meta.Model):
name = meta.CharField(maxlength=100)
description = meta.CharField(maxlength=250)
properties = meta.ManyToManyField_NoSyncdb('PropertyType',
db_table='app_propertytype_itemtypes')
class PropertyType(meta.Model):
name = meta.CharField(maxlength=100)
itemtypes = meta.ManyToManyField(ItemType)
免責聲明:這只是一個粗略的想法
編輯:有可能是成才做Django's 1.1 Proxy Models
相關機票:https://code.djangoproject.com/ticket/897 – guettli 2016-07-18 08:28:22