Changes between Version 12 and Version 13 of CookBookCategoryDataModel


Ignore:
Timestamp:
Dec 3, 2005, 5:50:25 AM (19 years ago)
Author:
Antonio Cavedoni
Comment:

Added syntax highlighting to the code samples

Legend:

Unmodified
Added
Removed
Modified
  • CookBookCategoryDataModel

    v12 v13  
    88== Code ==
    99{{{
     10#!python
    1011class Category(meta.Model):
    1112    category_name = meta.CharField(maxlength=50)
     
    5455Let's fill in some root-level categories:
    5556{{{
     57#!python
    5658>>> from yourpkg.apps.yourapp.models import yourapp
    5759>>> base_cats = [
     
    6971Now, let's create some sub categories, examining the dict as we go:
    7072{{{
     73#!python
    7174>>> cat = {'parent_id': 1, 'category_name': 'Python'}
    7275>>> new_cat = yourapp.Category(**cat)
     
    8689Now, let's add a few more and print all the categories:
    8790{{{
     91#!python
    8892>>> cat = {'parent_id': 2, 'category_name': 'Administration'}
    8993>>> yourapp.Category(**cat).save()
     
    103107== Usage in Other Data Models ==
    104108{{{
     109#!python
    105110class Document(meta.Model):
    106111    title = meta.CharField('title', maxlength=200),
Back to Top