Skip to content

Instantly share code, notes, and snippets.

@matthewharwood
Created August 16, 2015 01:17
Show Gist options
  • Save matthewharwood/946702d83e7eb30d8107 to your computer and use it in GitHub Desktop.
Save matthewharwood/946702d83e7eb30d8107 to your computer and use it in GitHub Desktop.
An ongoing example class of how to define models in python
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