2013-02-24 23:09:13 +00:00
|
|
|
from __future__ import unicode_literals
|
2013-01-29 05:28:09 +00:00
|
|
|
|
2013-02-24 23:09:13 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils import six
|
2013-01-29 05:28:09 +00:00
|
|
|
|
2013-02-24 23:09:13 +00:00
|
|
|
|
|
|
|
# The models definitions below used to crash. Generating models dynamically
|
|
|
|
# at runtime is a bad idea because it pollutes the app cache. This doesn't
|
|
|
|
# integrate well with the test suite but at least it prevents regressions.
|
|
|
|
|
|
|
|
|
|
|
|
class CustomBaseModel(models.base.ModelBase):
|
2013-01-29 05:28:09 +00:00
|
|
|
pass
|
2013-02-24 23:09:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MyModel(six.with_metaclass(CustomBaseModel, models.Model)):
|
|
|
|
"""Model subclass with a custom base using six.with_metaclass."""
|
|
|
|
|
|
|
|
|
|
|
|
if not six.PY3:
|
|
|
|
class MyModel(models.Model):
|
|
|
|
"""Model subclass with a custom base using __metaclass__."""
|
|
|
|
__metaclass__ = CustomBaseModel
|