Skip to content

Instantly share code, notes, and snippets.

@nidhinp
Created September 2, 2019 13:44
Show Gist options
  • Save nidhinp/c42f7967e257edd93029007d4b806b35 to your computer and use it in GitHub Desktop.
Save nidhinp/c42f7967e257edd93029007d4b806b35 to your computer and use it in GitHub Desktop.
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
def __str__(self):
return self.name
class Meta:
ordering = ('name', )
class Book(models.Model):
title = models.CharField(max_length=100)
synopsis = models.TextField()
author = models.ForeignKey(
"info.Author", related_name="books", on_delete=models.CASCADE)
published_date = models.DateField()
def __str__(self):
return self.title
class Meta:
ordering = ('title', )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment