Changeset 3031
- Timestamp:
- 05/31/06 14:23:07 (2 years ago)
- Files:
-
- django/trunk/tests/modeltests/field_defaults/models.py (modified) (3 diffs)
- django/trunk/tests/modeltests/m2m_and_m2o/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2m_recursive/models.py (modified) (12 diffs)
- django/trunk/tests/modeltests/manipulators/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/pagination/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/validation/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/modeltests/field_defaults/models.py
r2809 r3031 1 1 """ 2 XXX. Callable defaults2 31. Callable defaults 3 3 4 ??? 4 You can pass callable objects as the ``default`` parameter to a field. When 5 the object is created without an explicit value passed in, Django will call 6 the method to determine the default value. 7 8 This example uses ``datetime.datetime.now`` as the default for the ``pub_date`` 9 field. 5 10 """ 6 11 … … 10 15 class Article(models.Model): 11 16 headline = models.CharField(maxlength=100, default='Default headline') 12 pub_date = models.DateTimeField(default =datetime.now)13 14 def __ repr__(self):17 pub_date = models.DateTimeField(default=datetime.now) 18 19 def __str__(self): 15 20 return self.headline 16 21 … … 44 49 >>> d.seconds < 5 45 50 True 46 47 48 51 """ django/trunk/tests/modeltests/m2m_and_m2o/models.py
r3030 r3031 1 1 """ 2 2 7. Many-to-many and many-to-one relationships to the same table2 28. Many-to-many and many-to-one relationships to the same table 3 3 4 This is a response to bug #1535 5 4 Make sure to set ``related_name`` if you use relationships to the same table. 6 5 """ 7 6 … … 15 14 cc = models.ManyToManyField(User, blank=True, related_name='test_issue_cc') 16 15 client = models.ForeignKey(User, related_name='test_issue_client') 17 def __repr__(self): 18 return "<Issue %d>" % (self.num,) 16 17 def __str__(self): 18 return str(self.num) 19 19 20 20 class Meta: django/trunk/tests/modeltests/m2m_recursive/models.py
r2809 r3031 1 1 """ 2 2 6. Many-to-many relationships between the same two tables2 27. Many-to-many relationships between the same two tables 3 3 4 In this example, A Person can have many friends, who are also people. Friendship is a 4 In this example, A Person can have many friends, who are also people. Friendship is a 5 5 symmetrical relationshiup - if I am your friend, you are my friend. 6 6 7 7 A person can also have many idols - but while I may idolize you, you may not think 8 the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive 8 the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive 9 9 m2m fields may be non-symmetrical, and they are symmetrical by default. 10 10 11 11 This test validates that the m2m table will create a mangled name for the m2m table if 12 there will be a clash, and tests that symmetry is preserved where appropriate. 12 there will be a clash, and tests that symmetry is preserved where appropriate. 13 13 """ 14 14 … … 41 41 42 42 # Who is friends with Anne? 43 >>> a.friends.all() 43 >>> a.friends.all() 44 44 [Bill, Chuck, David] 45 45 … … 53 53 54 54 # Who is friends with David? 55 >>> d.friends.all() 55 >>> d.friends.all() 56 56 [Anne, Chuck] 57 57 … … 60 60 61 61 # Who is friends with Anne? 62 >>> a.friends.all() 62 >>> a.friends.all() 63 63 [Bill, Chuck, David] 64 64 … … 71 71 72 72 # Who is friends with Anne? 73 >>> a.friends.all() 73 >>> a.friends.all() 74 74 [Chuck, David] 75 75 … … 82 82 83 83 # Who is friends with Anne? 84 >>> a.friends.all() 84 >>> a.friends.all() 85 85 [] 86 86 … … 91 91 92 92 # Who is friends with David? 93 >>> d.friends.all() 93 >>> d.friends.all() 94 94 [Chuck] 95 95 … … 106 106 107 107 # Who are Anne's idols? 108 >>> a.idols.all() 108 >>> a.idols.all() 109 109 [Bill, Chuck, David] 110 110 … … 141 141 142 142 # Who are Anne's idols? 143 >>> a.idols.all() 143 >>> a.idols.all() 144 144 [Bill, Chuck, David] 145 145 … … 159 159 160 160 # Who are Anne's idols? 161 >>> a.idols.all() 161 >>> a.idols.all() 162 162 [Chuck, David] 163 163 … … 178 178 179 179 # Who are Anne's idols 180 >>> a.idols.all() 180 >>> a.idols.all() 181 181 [] 182 182 … … 187 187 188 188 # Who is friends with David? 189 >>> d.stalkers.all() 189 >>> d.stalkers.all() 190 190 [Chuck] 191 191 django/trunk/tests/modeltests/manipulators/models.py
r3028 r3031 1 1 """ 2 2 5. Default manipulators2 26. Default manipulators 3 3 4 4 Each model gets an AddManipulator and ChangeManipulator by default. django/trunk/tests/modeltests/pagination/models.py
r3030 r3031 1 1 """ 2 2 8. Object pagination2 29. Object pagination 3 3 4 4 Django provides a framework for paginating a list of objects in a few lines django/trunk/tests/modeltests/validation/models.py
r3030 r3031 1 1 """ 2 29. Validation2 30. Validation 3 3 4 4 This is an experimental feature!
