Created
August 16, 2015 01:17
-
-
Save matthewharwood/946702d83e7eb30d8107 to your computer and use it in GitHub Desktop.
An ongoing example class of how to define models in python
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
from django.db import models | |
# Create your models here. | |
class Project(models.Model): | |
name = models.CharField(max_length=300) | |
def __unicode__(self): | |
return self.name | |
class Task(models.Model): | |
description = models.CharField(max_length=300) | |
project = models.ForeignKey(Project) | |
def __unicode__(self): | |
return self.description |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment