summaryrefslogtreecommitdiff
path: root/tests/auth_tests/models
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-02-11 14:38:52 -0500
committerTim Graham <timograham@gmail.com>2015-02-12 07:38:16 -0500
commit0f7f5bc9e7a94ab91c2b3db29ef7cf000eff593f (patch)
tree17168b2dcd85eab4a78cba0596ee2120f889baab /tests/auth_tests/models
parent93b3ef9b2e191101c1a49b332d042864df74a658 (diff)
Fixed #24161 -- Stored the user primary key as a serialized value in the session.
This allows using a UUIDField primary key along with the JSON session serializer. Thanks to Trac alias jamesbeith for the report and Simon Charette for the initial patch.
Diffstat (limited to 'tests/auth_tests/models')
-rw-r--r--tests/auth_tests/models/__init__.py3
-rw-r--r--tests/auth_tests/models/uuid_pk.py13
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/auth_tests/models/__init__.py b/tests/auth_tests/models/__init__.py
index edeaef5347..72afdf2358 100644
--- a/tests/auth_tests/models/__init__.py
+++ b/tests/auth_tests/models/__init__.py
@@ -5,9 +5,10 @@ from .invalid_models import (
CustomUserBadRequiredFields,
)
from .with_foreign_key import CustomUserWithFK, Email
+from .uuid_pk import UUIDUser
__all__ = (
'CustomPermissionsUser', 'CustomUserNonUniqueUsername',
'CustomUserNonListRequiredFields', 'CustomUserBadRequiredFields',
- 'CustomUserWithFK', 'Email', 'IsActiveTestUser1',
+ 'CustomUserWithFK', 'Email', 'IsActiveTestUser1', 'UUIDUser',
)
diff --git a/tests/auth_tests/models/uuid_pk.py b/tests/auth_tests/models/uuid_pk.py
new file mode 100644
index 0000000000..44ec4410aa
--- /dev/null
+++ b/tests/auth_tests/models/uuid_pk.py
@@ -0,0 +1,13 @@
+import uuid
+
+from django.contrib.auth.models import AbstractUser
+from django.contrib.auth.tests.custom_user import RemoveGroupsAndPermissions
+from django.db import models
+
+with RemoveGroupsAndPermissions():
+ class UUIDUser(AbstractUser):
+ """A user with a UUID as primary key"""
+ id = models.UUIDField(default=uuid.uuid4, primary_key=True)
+
+ class Meta:
+ app_label = 'auth'