Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pydantic · Pipe

populate_by_name

Enables aliased fields to accept input by their Python attribute names as well as their aliases. It defaults to false and is not recommended from Pydantic v2.11 onward because it will be deprecated in v3.

Since
2.0

How it works

When enabled, an aliased field accepts input under both its Python attribute name and its configured alias. The setting defaults to false, and current documentation advises replacing it with validate_by_name together with validate_by_alias because populate_by_name is deprecated for Pydantic v3.

Syntax

ConfigDict(populate_by_name=True)

Parameters

NameTypeDescription
populate_by_nameboolWhether aliased fields may also be populated using their model attribute names.

Returns

A model configuration setting; it does not return a value.

Key points

  • It controls whether an aliased field accepts its model attribute name as input.
  • When enabled, the alias remains accepted alongside the attribute name.
  • If not configured, the setting is disabled.
  • For newer code, prefer validate_by_name; pair it with validate_by_alias when both forms should be accepted.
  • The replacement validation controls cannot both be disabled because the model would have no permitted population route.
  • The documentation identifies this as the configuration approach used in Pydantic v2.0 through v2.10.

Common mistakes

  • Avoid this setting for new code targeting current Pydantic releases; use validate_by_name and validate_by_alias instead.

Example: Populate an aliased field by name

from pydantic import BaseModel, ConfigDict, Field

class Model(BaseModel):
    model_config = ConfigDict(populate_by_name=True)
    my_field: str = Field(alias='my_alias')

print(Model(my_field='value'))
print(Model(my_alias='value'))

Both the field name and its alias can be used when creating the model.

When to use it

Support dual input naming

A model must accept payloads that use either internal Python field names or external aliases.

Maintain older Pydantic behavior

A migration temporarily needs the older v2.0-v2.10 population behavior.

Interview questions

QWhat does populate_by_name do?

It allows an aliased field to be populated using either the model attribute name or its alias. The default is false, so only the configured behavior is available unless the setting is enabled.

Follow-up: What should replace it in newer Pydantic code? Use validate_by_name=True and validate_by_alias=True in ConfigDict.

QWhat is its default behavior?

The setting defaults to false. With it enabled, a field declared with an alias can receive input using its Python name as well as that alias.

Follow-up: Why might enabling both validation options be necessary? It preserves acceptance of both naming forms while avoiding the deprecated setting.

QIs populate_by_name still recommended?

The current documentation says its use is not recommended from v2.11 onward and that it will be deprecated in v3. The recommended replacement is separate validation controls for names and aliases.

Follow-up: Can both replacement options be disabled? No; the documentation states that disabling both would make it impossible to populate an attribute.

  • ConfigDict
  • Field
  • validate_by_name
  • validate_by_alias

Source: Configuration - Pydantic. Checked 2026-10-15.