tortoise / tortoise/tortoise-orm
How to select parent that contains certain children from his ManyToMany relation?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Given this piece of code:
class Recipe(Model):
description = fields.CharField(max_length=1024)
ingredients = fields.ManyToManyField(model_name="models.Ingredient", on_delete=fields.SET_NULL)
class Ingredient(Model):
name = fields.CharField(max_length=128)
How to query all recipes that contain BOTH Ingredient.name="tomato" and Ingredient.name="onion" ?
I believe that in Django-ORM it was possible to make some intersection of QuerySets using & operator or intersect method.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation file or test is identified in the issue. Start by checking Tortoise ORM's relation-filtering and QuerySet documentation and source to determine whether selecting recipes with both named ingredients is supported. Done should be a documented, reproducible way to express this query, or a clearly scoped feature proposal if it is not supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100