We have 2 models.
class News(models.Model): title = models.CharField(max_length=250) еще дата публ, кол-во просмотров и т.д. class Images(models.Model): image = models.ImageField(upload_to="news/images/%m.%Y") news = models.ForeignKey(News, related_name='images2news') News can have> = 0 images. How to choose all the news along with the pictures if the news of course they are?
There is already an incorrect implementation that generates duplicates.
News.objects.filter(site=1).values('pk', 'title', 'text', 'changed', "images__image").order_by("-changed").distinct()