| 1 |
from django.apps.registry import Apps |
| 2 |
from django.db import models |
| 3 |
|
| 4 |
|
| 5 |
class CustomModelBase(models.base.ModelBase): |
| 6 |
pass |
| 7 |
|
| 8 |
|
| 9 |
class ModelWithCustomBase(models.Model, metaclass=CustomModelBase): |
| 10 |
pass |
| 11 |
|
| 12 |
|
| 13 |
class UnicodeModel(models.Model): |
| 14 |
title = models.CharField("ÚÑÍ¢ÓÐÉ", max_length=20, default="“Ðjáñgó”") |
| 15 |
|
| 16 |
class Meta: |
| 17 |
# Disable auto loading of this model as we load it on our own |
| 18 |
apps = Apps() |
| 19 |
verbose_name = "úñí©óðé µóðéø" |
| 20 |
verbose_name_plural = "úñí©óðé µóðéøß" |
| 21 |
|
| 22 |
def __str__(self): |
| 23 |
return self.title |
| 24 |
|
| 25 |
|
| 26 |
class Unserializable: |
| 27 |
""" |
| 28 |
An object that migration doesn't know how to serialize. |
| 29 |
""" |
| 30 |
|
| 31 |
pass |
| 32 |
|
| 33 |
|
| 34 |
class UnserializableModel(models.Model): |
| 35 |
title = models.CharField(max_length=20, default=Unserializable()) |
| 36 |
|
| 37 |
class Meta: |
| 38 |
# Disable auto loading of this model as we load it on our own |
| 39 |
apps = Apps() |
| 40 |
|
| 41 |
|
| 42 |
class UnmigratedModel(models.Model): |
| 43 |
""" |
| 44 |
A model that is in a migration-less app (which this app is |
| 45 |
if its migrations directory has not been repointed) |
| 46 |
""" |
| 47 |
|
| 48 |
pass |
| 49 |
|
| 50 |
|
| 51 |
class EmptyManager(models.Manager): |
| 52 |
use_in_migrations = True |
| 53 |
|
| 54 |
|
| 55 |
class FoodQuerySet(models.query.QuerySet): |
| 56 |
pass |
| 57 |
|
| 58 |
|
| 59 |
class BaseFoodManager(models.Manager): |
| 60 |
def __init__(self, a, b, c=1, d=2): |
| 61 |
super().__init__() |
| 62 |
self.args = (a, b, c, d) |
| 63 |
|
| 64 |
|
| 65 |
class FoodManager(BaseFoodManager.from_queryset(FoodQuerySet)): |
| 66 |
use_in_migrations = True |
| 67 |
|
| 68 |
|
| 69 |
class NoMigrationFoodManager(BaseFoodManager.from_queryset(FoodQuerySet)): |
| 70 |
pass |