| 1 |
from polymorphic.models import PolymorphicModel |
| 2 |
from polymorphic.managers import PolymorphicManager |
| 3 |
from django.db import models |
| 4 |
from django.db.models import Manager |
| 5 |
from django.db.models.query import QuerySet |
| 6 |
|
| 7 |
|
| 8 |
class BadModel(PolymorphicModel): |
| 9 |
instance_of = models.CharField(max_length=100) |
| 10 |
not_instance_of = models.IntegerField() |
| 11 |
|
| 12 |
|
| 13 |
class PolymorphicMigrationManager(PolymorphicManager): |
| 14 |
use_in_migrations = True |
| 15 |
|
| 16 |
|
| 17 |
class OkMigrationManager(Manager): |
| 18 |
use_in_migrations = True |
| 19 |
|
| 20 |
|
| 21 |
class GoodMigrationManager(PolymorphicModel): |
| 22 |
objects = PolymorphicManager() |
| 23 |
migration_manager = OkMigrationManager() |
| 24 |
|
| 25 |
|
| 26 |
class BadMigrationManager(PolymorphicModel): |
| 27 |
objects = PolymorphicMigrationManager() |
| 28 |
|
| 29 |
|
| 30 |
class BadManager(PolymorphicModel): |
| 31 |
objects = models.Manager() # not polymorphic |
| 32 |
|
| 33 |
|
| 34 |
class BadQuerySet(PolymorphicModel): |
| 35 |
default_objects = PolymorphicManager().from_queryset(QuerySet) |