From a0ab068449cde36c017990987909b0a52b9a4c96 Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Sun, 7 Apr 2013 22:16:41 +0200 Subject: [PATCH] Included Proxy models in example app. --- example/pexp/admin.py | 12 ++++++++++++ example/pexp/models.py | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/example/pexp/admin.py b/example/pexp/admin.py index 5eb48fc..43b095b 100644 --- a/example/pexp/admin.py +++ b/example/pexp/admin.py @@ -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) diff --git a/example/pexp/models.py b/example/pexp/models.py index a21e53e..b0ed8c5 100644 --- a/example/pexp/models.py +++ b/example/pexp/models.py @@ -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"".format(self.polymorphic_ctype, self.title) + + class Meta: + ordering = ('title',) + +class ProxyA(ProxyBase): + class Meta: + proxy = True + + def __unicode__(self): + return u"".format(self.title) + +class ProxyB(ProxyBase): + class Meta: + proxy = True + + def __unicode__(self): + return u"".format(self.title)