from django.db import models from django.contrib.auth.models import User class Tag(models.Model): Name = models.CharField(blank=False, max_length=50) class ArticleClass(models.Model): Name = models.CharField(blank=False, max_length=50) class Article(models.Model): ArticleId = models.AutoField(primary_key=True) Publisher = models.ForeignKey(User, on_delete=models.CASCADE, related_name='Publisher') Title = models.CharField(blank=False, max_length=50) Content = models.TextField(blank=False) Cover = models.URLField(blank=True, max_length=5000) Read = models.IntegerField() Like = models.IntegerField() Publish_Time = models.DateTimeField(auto_now_add=True) Edit_Time = models.DateTimeField(auto_now=True) Tag = models.ManyToManyField(Tag, blank=True) Class = models.ForeignKey(ArticleClass, on_delete=models.SET_NULL, null=True) class Draft(models.Model): DraftId = models.AutoField(primary_key=True) Poster = models.ForeignKey(User, on_delete=models.CASCADE, related_name='Poster') Title = models.CharField(blank=True, max_length=50) Content = models.TextField(blank=True) Add_Time = models.DateTimeField(auto_now_add=True) Edit_Time = models.DateTimeField(auto_now=True)