- renamed ShowField* to ShowFieldType, ShowFieldContent, ShowFieldTypeAndContent, in order to reflect better what they do.
- by default, django_polymorphic's pretty printing of querysets/objects (via ShowField*) is not used anymore - ShowField mixins now also show the annotations (after the regular fields, prepended by "Ann:") - cleaned up implementation.
This commit is contained in:
@@ -22,13 +22,15 @@ class Command(NoArgsCommand):
|
||||
def handle_noargs(self, **options):
|
||||
print 'polycmd - sqlite test db is stored in:',settings.DATABASE_NAME
|
||||
print
|
||||
|
||||
|
||||
"""
|
||||
ModelA.objects.all().delete()
|
||||
o=ModelA.objects.create(field1='A1')
|
||||
o=ModelB.objects.create(field1='B1', field2='B2')
|
||||
o=ModelC.objects.create(field1='C1', field2='C2', field3='C3')
|
||||
print ModelA.objects.all()
|
||||
print
|
||||
"""
|
||||
|
||||
Project.objects.all().delete()
|
||||
o=Project.objects.create(topic="John's gathering")
|
||||
|
||||
+4
-9
@@ -2,29 +2,24 @@
|
||||
|
||||
from django.db import models
|
||||
|
||||
from polymorphic import PolymorphicModel, PolymorphicManager, PolymorphicQuerySet, ShowFields, ShowFieldsAndTypes
|
||||
from polymorphic import PolymorphicModel, PolymorphicManager, PolymorphicQuerySet
|
||||
from polymorphic.showfields import ShowFieldContent, ShowFieldType, ShowFieldTypeAndContent
|
||||
|
||||
|
||||
class Project(ShowFields, PolymorphicModel):
|
||||
class Project(ShowFieldContent, PolymorphicModel):
|
||||
topic = models.CharField(max_length=30)
|
||||
class ArtProject(Project):
|
||||
artist = models.CharField(max_length=30)
|
||||
class ResearchProject(Project):
|
||||
supervisor = models.CharField(max_length=30)
|
||||
|
||||
class ModelA(PolymorphicModel):
|
||||
class ModelA(ShowFieldType, PolymorphicModel):
|
||||
field1 = models.CharField(max_length=10)
|
||||
class ModelB(ModelA):
|
||||
field2 = models.CharField(max_length=10)
|
||||
class ModelC(ModelB):
|
||||
field3 = models.CharField(max_length=10)
|
||||
|
||||
class SModelA(ShowFieldsAndTypes, PolymorphicModel):
|
||||
field1 = models.CharField(max_length=10)
|
||||
class SModelB(SModelA):
|
||||
field2 = models.CharField(max_length=10)
|
||||
class SModelC(SModelB):
|
||||
field3 = models.CharField(max_length=10)
|
||||
|
||||
# for Django 1.2+, test models with same names in different apps
|
||||
# (the other models with identical names are in polymorphic/tests.py)
|
||||
|
||||
Reference in New Issue
Block a user