Changes between Version 12 and Version 13 of CookBookCategoryDataModel
- Timestamp:
- Dec 3, 2005, 5:50:25 AM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBookCategoryDataModel
v12 v13 8 8 == Code == 9 9 {{{ 10 #!python 10 11 class Category(meta.Model): 11 12 category_name = meta.CharField(maxlength=50) … … 54 55 Let's fill in some root-level categories: 55 56 {{{ 57 #!python 56 58 >>> from yourpkg.apps.yourapp.models import yourapp 57 59 >>> base_cats = [ … … 69 71 Now, let's create some sub categories, examining the dict as we go: 70 72 {{{ 73 #!python 71 74 >>> cat = {'parent_id': 1, 'category_name': 'Python'} 72 75 >>> new_cat = yourapp.Category(**cat) … … 86 89 Now, let's add a few more and print all the categories: 87 90 {{{ 91 #!python 88 92 >>> cat = {'parent_id': 2, 'category_name': 'Administration'} 89 93 >>> yourapp.Category(**cat).save() … … 103 107 == Usage in Other Data Models == 104 108 {{{ 109 #!python 105 110 class Document(meta.Model): 106 111 title = meta.CharField('title', maxlength=200),