tortoise / tortoise/tortoise-orm
Exclude any FK fields in pydantic_model_creator
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
class User(models.Model):
id = fields.IntField(pk=True)
username = fields.CharField(max_length=128, index=True, unique=True)
email = fields.CharField(max_length=128, unique=True, index=True)
class Event(models.Model):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=128)
user = fields.ForeignKeyField("models.User", related_name="events")
It would be nice to add such a solution:
Event_Pydantic = pydantic_model_creator(Event, exclude=("user__email",))
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
Start by locating pydantic_model_creator and reading how its existing exclude option handles related fields. Check the current tests around Pydantic model creation, then define done as allowing the shown Event example to exclude user__email without excluding unrelated fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100