Answer the question
In order to leave comments, you need to log in
How to output objects in Django with filtering if ManyToMany matches?
There is a problem in the implementation of the code.
class Course(models.Model):
title = models.CharField("Название курса", max_length=36)
description = models.TextField("Описание курса", max_length=60)
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='author')
pubdate = models.DateTimeField("Время создания")
preview = models.ImageField(upload_to='media/preview/')
duration = models.PositiveIntegerField("Продолжительность курса в часах", validators=[MaxValueValidator(999)])
amount = models.PositiveIntegerField("Количество лекций в курсе", validators=[MaxValueValidator(999)])
category = models.ForeignKey(Category, verbose_name="Категория", on_delete=models.CASCADE)
price = models.PositiveIntegerField("Цена", validators=[MaxValueValidator(99999)])
lessons = models.ManyToManyField(Lesson, verbose_name="Уроки", blank=True)
owners = models.ManyToManyField(settings.AUTH_USER_MODEL, verbose_name="Владельцы", blank=True, related_name='owners')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question