2007-11-05 13:59:42 +00:00
|
|
|
"""
|
|
|
|
Tests for field subclassing.
|
|
|
|
"""
|
|
|
|
|
2011-10-13 18:04:12 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2007-11-05 13:59:42 +00:00
|
|
|
from django.db import models
|
2012-07-21 08:00:10 +00:00
|
|
|
from django.utils.encoding import force_text
|
2007-11-05 13:59:42 +00:00
|
|
|
|
2011-10-13 18:04:12 +00:00
|
|
|
from .fields import SmallField, SmallerField, JSONField
|
2007-11-05 13:59:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MyModel(models.Model):
|
|
|
|
name = models.CharField(max_length=10)
|
|
|
|
data = SmallField('small field')
|
|
|
|
|
|
|
|
def __unicode__(self):
|
2012-07-21 08:00:10 +00:00
|
|
|
return force_text(self.name)
|
2007-11-05 13:59:42 +00:00
|
|
|
|
2010-11-02 18:40:53 +00:00
|
|
|
class OtherModel(models.Model):
|
|
|
|
data = SmallerField()
|
|
|
|
|
2010-02-24 19:06:59 +00:00
|
|
|
class DataModel(models.Model):
|
|
|
|
data = JSONField()
|