aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/tests/models.py')
-rw-r--r--rest_framework/tests/models.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/rest_framework/tests/models.py b/rest_framework/tests/models.py
index c90668ca..969c8297 100644
--- a/rest_framework/tests/models.py
+++ b/rest_framework/tests/models.py
@@ -28,25 +28,34 @@ from django.db import models
# 'pk': self.id
# })
-class Anchor(models.Model):
+def foobar():
+ return 'foobar'
+
+
+class RESTFrameworkModel(models.Model):
"""
- A simple model to use as the target of relationships for other test models.
+ Base for test models that sets app_label, so they play nicely.
"""
- text = models.CharField(max_length=100, default='anchor')
-
class Meta:
app_label = 'rest_framework'
+ abstract = True
-class BasicModel(models.Model):
+class Anchor(RESTFrameworkModel):
+ text = models.CharField(max_length=100, default='anchor')
+
+
+class BasicModel(RESTFrameworkModel):
text = models.CharField(max_length=100)
- class Meta:
- app_label = 'rest_framework'
+class DefaultValueModel(RESTFrameworkModel):
+ text = models.CharField(default='foobar', max_length=100)
-class ManyToManyModel(models.Model):
- rel = models.ManyToManyField(Anchor)
- class Meta:
- app_label = 'rest_framework'
+class CallableDefaultValueModel(RESTFrameworkModel):
+ text = models.CharField(default=foobar, max_length=100)
+
+
+class ManyToManyModel(RESTFrameworkModel):
+ rel = models.ManyToManyField(Anchor)