Answers for "django many to many field"

0

django many to many field

from django.db import models

class Publication(models.Model):
    title = models.CharField(max_length=30)

    class Meta:
        ordering = ['title']

    def __str__(self):
        return self.title

class Article(models.Model):
    headline = models.CharField(max_length=100)
    publications = models.ManyToManyField(Publication)

    class Meta:
        ordering = ['headline']

    def __str__(self):
        return self.headline
Posted by: Guest on May-03-2022

Code answers related to "django many to many field"

Python Answers by Framework

Browse Popular Code Answers by Language