aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/models.py
diff options
context:
space:
mode:
authorCraig Blaszczyk2011-07-08 17:37:20 +0100
committerCraig Blaszczyk2011-07-08 17:37:20 +0100
commit6e6b35b5c03d66f612e55c29e11d3096cd2703ac (patch)
treec4ca927eb820bac9f0e8817bed0d883069985e2c /djangorestframework/tests/models.py
parent8a2944acdf66a966f0bd4ea4770f012f2597fb4e (diff)
downloaddjango-rest-framework-6e6b35b5c03d66f612e55c29e11d3096cd2703ac.tar.bz2
add unit tests which show m2m creation failing for through table
Diffstat (limited to 'djangorestframework/tests/models.py')
-rw-r--r--djangorestframework/tests/models.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/djangorestframework/tests/models.py b/djangorestframework/tests/models.py
new file mode 100644
index 00000000..61da1d45
--- /dev/null
+++ b/djangorestframework/tests/models.py
@@ -0,0 +1,28 @@
+from django.db import models
+from django.contrib.auth.models import Group
+
+class CustomUser(models.Model):
+ """
+ A custom user model, which uses a 'through' table for the foreign key
+ """
+ username = models.CharField(max_length=255, unique=True)
+ groups = models.ManyToManyField(
+ to=Group, blank=True, null=True, through='UserGroupMap'
+ )
+
+ @models.permalink
+ def get_absolute_url(self):
+ return ('custom_user', (), {
+ 'pk': self.id
+ })
+
+
+class UserGroupMap(models.Model):
+ user = models.ForeignKey(to=CustomUser)
+ group = models.ForeignKey(to=Group)
+
+ @models.permalink
+ def get_absolute_url(self):
+ return ('user_group_map', (), {
+ 'pk': self.id
+ }) \ No newline at end of file