annotate examples/project/zoo/models.py @ 0:ff263bdd455e

initial checkin
author Victor Ng <victor@monkeybean.ca>
date Thu, 28 Aug 2008 09:44:43 -0400
parents
children 8d0793b2358b
rev   line source
0
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
1 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
2 Module-level doctest.
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
3
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
4 >>> Zoo
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
5 <class 'project.zoo.models.Zoo'>
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
6 >>> 1 + 1
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
7 2
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
8 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
9 from django.db import models
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
10
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
11 # Create your models here.
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
12 class Zoo(models.Model):
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
13 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
14 Class-level doctest
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
15
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
16 >>> Zoo
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
17 <class 'project.zoo.models.Zoo'>
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
18 >>> 1 + 1
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
19 2
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
20 >>> Zoo.objects.all()
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
21 []
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
22 >>> z = Zoo(name='Bronx')
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
23 >>> z.save()
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
24 >>> z
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
25 <Zoo: Bronx>
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
26 >>> Zoo.objects.all()
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
27 [<Zoo: Bronx>]
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
28 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
29 name = models.CharField(max_length=100)
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
30
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
31 def __str__(self):
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
32 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
33 Function in class test
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
34 >>> 1 + 2
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
35 3
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
36 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
37 return self.name
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
38
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
39 def func():
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
40 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
41 Function-level test
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
42 >>> 1+3
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
43 4
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
44 """
ff263bdd455e initial checkin
Victor Ng <victor@monkeybean.ca>
parents:
diff changeset
45 pass