mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
f9cf6b42f4
* adding create_model method * adding method * docs and tweaks * prevent config and base together * tweak docs
14 lines
322 B
Python
14 lines
322 B
Python
from pydantic import BaseModel, create_model
|
|
|
|
|
|
class FooModel(BaseModel):
|
|
foo: str
|
|
bar: int = 123
|
|
|
|
|
|
BarModel = create_model('BarModel', apple='russet', banana='yellow', __base__=FooModel)
|
|
print(BarModel)
|
|
# > <class 'pydantic.main.BarModel'>
|
|
print(', '.join(BarModel.__fields__.keys()))
|
|
# > foo, bar, apple, banana
|