Created
July 14, 2009 03:01
-
-
Save gabrielfalcao/146676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8; -*- | |
# | |
# Copyright (C) 2009 Gabriel Falcão <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License as | |
# published by the Free Software Foundation; either version 2 of the | |
# License, or (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
# General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public | |
# License along with this program; if not, write to the | |
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
# Boston, MA 02111-1307, USA. | |
from deadparrot import models | |
class Person(models.Model): | |
name = models.CharField(max_length=100, primary_key=True) | |
class Recipe(models.Model): | |
description = models.CharField(max_length=100, primary_key=True) | |
baker = models.ForeignKey(Person) | |
# here is the big deal: | |
objects = models.FileSystemModelManager(base_path='.') | |
Recipe.objects.create(description='Egg Cake', baker=Person(name='Paulo')) | |
Recipe.objects.create(description='Chocolate Cake', baker=Person(name='Paulo')) | |
chocolate_cake = Recipe.objects.filter(description='Chocolate Cake')[0] | |
assert chocolate_cake.description == 'Chocolate Cake' | |
assert chocolate_cake.baker.name == 'Paulo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment