Created
September 2, 2019 13:44
-
-
Save nidhinp/c42f7967e257edd93029007d4b806b35 to your computer and use it in GitHub Desktop.
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 | |
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