Created
March 2, 2014 12:20
-
-
Save mineta/9305782 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Based on Example in https://docs.djangoproject.com/en/1.5/topics/testing/doctests/ | |
from django.db import models | |
class Animal(models.Model): | |
""" | |
An animal that makes noise | |
# Create an animal | |
>>> lion = Animal.objects.create(name="lion", sound="roar") | |
# Test it makes the correct noise | |
>>> lion.speak() | |
'The lion says "roar"' | |
""" | |
name = models.CharField(max_length=20) | |
sound = models.CharField(max_length=20) | |
def speak(self): | |
return 'The %s says "%s"' % (self.name, self.sound) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment