Answers for "Djngo: Design your model"

0

Djngo: Design your model

from django.db import models

class Reporter(models.Model):
    full_name = models.CharField(max_length=70)

    def __str__(self):
        return self.full_name

class Article(models.Model):
    pub_date = models.DateField()
    headline = models.CharField(max_length=200)
    content = models.TextField()
    reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)

    def __str__(self):
        return self.headline
Posted by: Guest on April-30-2021

Code answers related to "Djngo: Design your model"

Browse Popular Code Answers by Language