Skip to content

Instantly share code, notes, and snippets.

@clauda
Created October 23, 2017 04:28
Show Gist options
  • Save clauda/ec7f5aa55d4c4b1fa0b157a6b7d67ea3 to your computer and use it in GitHub Desktop.
Save clauda/ec7f5aa55d4c4b1fa0b157a6b7d67ea3 to your computer and use it in GitHub Desktop.
My Django Project Sample
from django.db import models
from students.models impport Student
class Project(models.Model):
student = models.ForeignKey(Student)
name = models.CharField(max_length=200)
def __str__(self):
return self.name
class Notebook(models.Model):
project = models.ForeignKey(Project)
name = models.CharField(max_length=200)
description = models.TextField()
created_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
class Note(models.Model):
notebook = models.ForeignKey(Notebook)
annotation = models.TextField()
created_at = models.DateTimeField(auto_now=True)
updated_at = models.DateTimeField(null=True,blank=True)
def __str__(self):
return self.annotation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment