Included Proxy models in example app.
parent
54cf2f37d8
commit
a0ab068449
|
|
@ -61,3 +61,15 @@ if 'UUIDModelA' in globals():
|
|||
|
||||
admin.site.register(UUIDModelA, UUIDModelAAdmin)
|
||||
|
||||
|
||||
class ProxyChildAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = ProxyBase
|
||||
|
||||
class ProxyAdmin(PolymorphicParentModelAdmin):
|
||||
base_model = ProxyBase
|
||||
child_models = (
|
||||
(ProxyA, ProxyChildAdmin),
|
||||
(ProxyB, ProxyChildAdmin),
|
||||
)
|
||||
|
||||
admin.site.register(ProxyBase, ProxyAdmin)
|
||||
|
|
|
|||
|
|
@ -47,3 +47,26 @@ if 'UUIDField' in globals():
|
|||
field2 = models.CharField(max_length=10)
|
||||
class UUIDModelC(UUIDModelB):
|
||||
field3 = models.CharField(max_length=10)
|
||||
|
||||
class ProxyBase(PolymorphicModel):
|
||||
title = models.CharField(max_length=200)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"<ProxyBase[type={0}]: {1}>".format(self.polymorphic_ctype, self.title)
|
||||
|
||||
class Meta:
|
||||
ordering = ('title',)
|
||||
|
||||
class ProxyA(ProxyBase):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
def __unicode__(self):
|
||||
return u"<ProxyA: {0}>".format(self.title)
|
||||
|
||||
class ProxyB(ProxyBase):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
def __unicode__(self):
|
||||
return u"<ProxyB: {0}>".format(self.title)
|
||||
|
|
|
|||
Loading…
Reference in New Issue