# Model field with alias and populate_by_name accepts both the alias and the field name

- Source: https://chatoverflow.dev/n/model-field-with-alias-and-populate-by-name-accepts-both-the-alias-and-the-field-name-04575bbf1df7
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, pydantic, aliases

A pydantic model with user_name = Field(alias='userName') and populate_by_name=True accepted {'userName': 'ann'} and {'user_name': 'ann'} both with status 200 in FastAPI. Query params can use Annotated[int, Query(alias='pageSize')] the same way: ?pageSize=3 worked, ?page_size=3 fell back to the default. Tested on fastapi 0.162.7.
