summaryrefslogtreecommitdiff
path: root/tests/modeltests/custom_pk/models.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2006-06-06 01:21:49 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2006-06-06 01:21:49 +0000
commite976ed1f7910fad03704f88853c5c5b36cbab134 (patch)
treec4c8d32d4298f64ad9ce8e7813084c2f45a9dc40 /tests/modeltests/custom_pk/models.py
parent0c341d780ebcde0e81c81eda07e2db3aaa92549b (diff)
multi-auth: Merged to [3085]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@3086 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/custom_pk/models.py')
-rw-r--r--tests/modeltests/custom_pk/models.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/modeltests/custom_pk/models.py b/tests/modeltests/custom_pk/models.py
index fed2c25515..6193852adf 100644
--- a/tests/modeltests/custom_pk/models.py
+++ b/tests/modeltests/custom_pk/models.py
@@ -14,7 +14,7 @@ class Employee(models.Model):
class Meta:
ordering = ('last_name', 'first_name')
- def __repr__(self):
+ def __str__(self):
return "%s %s" % (self.first_name, self.last_name)
class Business(models.Model):
@@ -23,24 +23,24 @@ class Business(models.Model):
class Meta:
verbose_name_plural = 'businesses'
- def __repr__(self):
+ def __str__(self):
return self.name
API_TESTS = """
>>> dan = Employee(employee_code='ABC123', first_name='Dan', last_name='Jones')
>>> dan.save()
>>> Employee.objects.all()
-[Dan Jones]
+[<Employee: Dan Jones>]
>>> fran = Employee(employee_code='XYZ456', first_name='Fran', last_name='Bones')
>>> fran.save()
>>> Employee.objects.all()
-[Fran Bones, Dan Jones]
+[<Employee: Fran Bones>, <Employee: Dan Jones>]
>>> Employee.objects.get(pk='ABC123')
-Dan Jones
+<Employee: Dan Jones>
>>> Employee.objects.get(pk='XYZ456')
-Fran Bones
+<Employee: Fran Bones>
>>> Employee.objects.get(pk='foo')
Traceback (most recent call last):
...
@@ -48,43 +48,43 @@ DoesNotExist: Employee matching query does not exist.
# Use the name of the primary key, rather than pk.
>>> Employee.objects.get(employee_code__exact='ABC123')
-Dan Jones
+<Employee: Dan Jones>
# Fran got married and changed her last name.
>>> fran = Employee.objects.get(pk='XYZ456')
>>> fran.last_name = 'Jones'
>>> fran.save()
>>> Employee.objects.filter(last_name__exact='Jones')
-[Dan Jones, Fran Jones]
+[<Employee: Dan Jones>, <Employee: Fran Jones>]
>>> Employee.objects.in_bulk(['ABC123', 'XYZ456'])
-{'XYZ456': Fran Jones, 'ABC123': Dan Jones}
+{'XYZ456': <Employee: Fran Jones>, 'ABC123': <Employee: Dan Jones>}
>>> b = Business(name='Sears')
>>> b.save()
>>> b.employees.add(dan, fran)
>>> b.employees.all()
-[Dan Jones, Fran Jones]
+[<Employee: Dan Jones>, <Employee: Fran Jones>]
>>> fran.business_set.all()
-[Sears]
+[<Business: Sears>]
>>> Business.objects.in_bulk(['Sears'])
-{'Sears': Sears}
+{'Sears': <Business: Sears>}
>>> Business.objects.filter(name__exact='Sears')
-[Sears]
+[<Business: Sears>]
>>> Business.objects.filter(pk='Sears')
-[Sears]
+[<Business: Sears>]
# Queries across tables, involving primary key
>>> Employee.objects.filter(business__name__exact='Sears')
-[Dan Jones, Fran Jones]
+[<Employee: Dan Jones>, <Employee: Fran Jones>]
>>> Employee.objects.filter(business__pk='Sears')
-[Dan Jones, Fran Jones]
+[<Employee: Dan Jones>, <Employee: Fran Jones>]
>>> Business.objects.filter(employees__employee_code__exact='ABC123')
-[Sears]
+[<Business: Sears>]
>>> Business.objects.filter(employees__pk='ABC123')
-[Sears]
+[<Business: Sears>]
>>> Business.objects.filter(employees__first_name__startswith='Fran')
-[Sears]
+[<Business: Sears>]
"""