Created
September 8, 2019 21:01
-
-
Save olegkovalov/e9ddacb705b79fa9fdf7763a1acd26c4 to your computer and use it in GitHub Desktop.
models
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 | |
from django_blog.apps.account.models import User | |
from django_blog.apps.common.models import CoreModel | |
class Tag(models.Model): | |
name = models.CharField(max_length=100, unique=True) | |
class Post(CoreModel): | |
title = models.CharField(max_length=100) | |
text = models.TextField() | |
tags = models.ManyToManyField(Tag, related_name='posts', blank=True) | |
author = models.ForeignKey(User, related_name='posts', on_delete=models.CASCADE, blank=True, null=True) | |
image = models.ImageField(null=True, blank=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment