Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save goutomroy/a654d8750afab230e95faa0472d9f416 to your computer and use it in GitHub Desktop.
Save goutomroy/a654d8750afab230e95faa0472d9f416 to your computer and use it in GitHub Desktop.
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