Created
June 8, 2019 11:22
-
-
Save goutomroy/a654d8750afab230e95faa0472d9f416 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
class Author(models.Model): | |
name = models.CharField(max_length=200) | |
email = models.EmailField() | |
def __str__(self): | |
return self.name | |
class Blog(models.Model): | |
name = models.CharField(max_length=100) | |
tagline = models.TextField() | |
def __str__(self): | |
return self.name | |
class Entry(models.Model): | |
blog = models.ForeignKey(Blog, on_delete=models.CASCADE) | |
headline = models.CharField(max_length=255) | |
body_text = models.TextField(blank=True) | |
likes = models.IntegerField(blank=True, default=0) | |
authors = models.ManyToManyField(Author, blank=True) | |
class Meta: | |
default_related_name = 'entries' | |
def __str__(self): | |
return self.headline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment