Changes between Version 12 and Version 13 of CookBookCategoryDataModel


Ignore:
Timestamp:
12/03/2005 05:50:25 AM (10 years ago)
Author:
verbosus
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