diff options
Diffstat (limited to 'rest_framework/tests/models.py')
| -rw-r--r-- | rest_framework/tests/models.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/rest_framework/tests/models.py b/rest_framework/tests/models.py index f6e5333b..70523fc0 100644 --- a/rest_framework/tests/models.py +++ b/rest_framework/tests/models.py @@ -35,6 +35,13 @@ def foobar(): return 'foobar' +class CustomField(models.CharField): + + def __init__(self, *args, **kwargs): + kwargs['max_length'] = 12 + super(CustomField, self).__init__(*args, **kwargs) + + class RESTFrameworkModel(models.Model): """ Base for test models that sets app_label, so they play nicely. @@ -113,12 +120,16 @@ class Comment(RESTFrameworkModel): class ActionItem(RESTFrameworkModel): title = models.CharField(max_length=200) done = models.BooleanField(default=False) + info = CustomField(default='---', max_length=12) # Models for reverse relations class BlogPost(RESTFrameworkModel): title = models.CharField(max_length=100) + def get_first_comment(self): + return self.blogpostcomment_set.all()[0] + class BlogPostComment(RESTFrameworkModel): text = models.TextField() @@ -157,4 +168,4 @@ class OptionalRelationModel(RESTFrameworkModel): # Model for RegexField class Book(RESTFrameworkModel): - isbn = models.CharField(max_length=13)
\ No newline at end of file + isbn = models.CharField(max_length=13) |
