0

I have a "Article" model, where I'm going to store links to a different number of images.

class Article(models.Model):

    name = models.CharField(max_length=200, null=False)
    created = models.DateTimeField()
    modified = models.DateTimeField()
    text = models.TextField(null=False)
    tags = models.ManyToManyField(Tag)
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    images = ???

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.id:
            self.created = timezone.now()
        self.modified = timezone.now()
        return super(User, self).save(*args, **kwargs)

class Image(models.Model)

    ...

How to implement model for this case? I'm using SQLite database.

shmnff
  • 647
  • 2
  • 15
  • 31

1 Answers1

0

Create an ’ArticleImage’ that either references table ‘Article’ and ‘Image’, or contains image URLs and references ‘Article’.

Martin
  • 619
  • 5
  • 13