summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-08-10 03:52:41 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-08-10 03:52:41 +0000
commit0660203afe66fbc663a4e0af93ec74cd61e2c712 (patch)
tree1a6f6f2ff56b1f0614dd431938fe7c3a6445b629 /tests
parent5b812ae02cfa1e80e959f0bf31e7f82138094bb5 (diff)
Added custom_pk unit tests, which fail because of #81
git-svn-id: http://code.djangoproject.com/svn/django/trunk@458 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/testapp/models/__init__.py2
-rw-r--r--tests/testapp/models/custom_pk.py28
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/testapp/models/__init__.py b/tests/testapp/models/__init__.py
index 2c81a27ef3..d76059ec74 100644
--- a/tests/testapp/models/__init__.py
+++ b/tests/testapp/models/__init__.py
@@ -1,3 +1,3 @@
__all__ = ['basic', 'repr', 'custom_methods', 'many_to_one', 'many_to_many',
'ordering', 'lookup', 'get_latest', 'm2m_intermediary', 'one_to_one',
- 'm2o_recursive', 'm2o_recursive2', 'save_delete_hooks']
+ 'm2o_recursive', 'm2o_recursive2', 'save_delete_hooks', 'custom_pk']
diff --git a/tests/testapp/models/custom_pk.py b/tests/testapp/models/custom_pk.py
new file mode 100644
index 0000000000..97750182d7
--- /dev/null
+++ b/tests/testapp/models/custom_pk.py
@@ -0,0 +1,28 @@
+"""
+14. Using a custom primary key
+
+By default, Django adds an ``"id"`` field to each model. But you can override
+this behavior by explicitly adding ``primary_key=True`` to a field.
+
+NOTE: This isn't yet supported. This model exists as a unit test that currently
+fails.
+"""
+
+from django.core import meta
+
+class Employee(meta.Model):
+ fields = (
+ meta.CharField('employee_code', maxlength=10, primary_key=True),
+ meta.CharField('first_name', maxlength=20),
+ meta.CharField('last_name', maxlength=20),
+ )
+
+ def __repr__(self):
+ return "%s %s" % (self.first_name, self.last_name)
+
+API_TESTS = """
+>>> e = employees.Employee(employee_code='ABC123', first_name='Dan', last_name='Jones')
+>>> e.save()
+>>> employees.get_list()
+[Dan Jones]
+"""