Changeset 2256
- Timestamp:
- 02/03/06 17:30:12 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/tests/modeltests/m2m_multiple/models.py
r2244 r2256 43 43 >>> a1 = Article(headline='Area man steals', pub_date=datetime(2005, 11, 27)) 44 44 >>> a1.save() 45 >>> a1.set_primary_categories([c2.id, c3.id]) 46 True 47 >>> a1.set_secondary_categories([c4.id]) 45 >>> a1.primary_categories.add(c2, c3) 46 >>> a1.secondary_categories.add(c4) 48 47 True 49 48 50 49 >>> a2 = Article(headline='Area man runs', pub_date=datetime(2005, 11, 28)) 51 50 >>> a2.save() 52 >>> a2.set_primary_categories([c1.id, c2.id]) 53 True 54 >>> a2.set_secondary_categories([c4.id]) 51 >>> a2.primary_categories.add(c1, c2) 52 >>> a2.secondary_categories.add(c4) 55 53 True 56 54 57 # The "primary_category" here comes from the "singular" parameter. If we hadn't58 # specified the "singular" parameter, Django would just use "category", which59 # would cause a conflict because the "primary_categories" and60 # "secondary_categories" fields both relate to Category.61 55 >>> a1.primary_categories.all() 62 56 [Crime, News] 63 57 64 # Ditto for the "primary_category" here.65 58 >>> a2.primary_categories.all() 66 59 [News, Sports] 67 60 68 # Ditto for the "secondary_category" here.69 61 >>> a1.secondary_categories.all() 70 62 [Life]
