Answer the question
In order to leave comments, you need to log in
How to get a certain number of connected objects from the database?
models.py:
class Section(MPTTModel):
class Meta:
db_table='Section'
section_text = models.CharField(verbose_name='Название раздела', max_length=100)
parent = TreeForeignKey(verbose_name='Родительский Раздел',to='self', null=True, blank=True, related_name='children')
class Question(models.Model):
class Meta:
db_table = 'Question'
section = models.ForeignKey(Section)
question_text = models.CharField(verbose_name='Описание вопроса', max_length=250)
sections = Section.objects.filter(pk__in=[1,2,3])
questions = Question.objects.filter(section__in=sections)
Answer the question
In order to leave comments, you need to log in
Make a selection with a limit for each id separately: Nothing
else.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question