django-ninja
django-ninja copied to clipboard
[BUG] Field serialized when using repr=False
trafficstars
Fields are still included when using repr=False. Look at the following example:
Expected behaviour is to have fields with repr=False to not serialize, or am I missing something? :)
from pydantic import BaseModel, Field
from ninja import Schema
class ModelExample(BaseModel):
height: int
width: int
area: int = Field(repr=False)
### or
@computed_field(repr=False)
@cached_property
def area(self) -> int:
return height*width
class OutSchema(ModelExample, Schema):
pass
Versions (please complete the following information):
- Python version: 3.12
- Django version: 5.01
- Django-Ninja version: 1.2.x
- Pydantic version: 2.x