mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
13b002e97f
* Add change file * Add datetime field to default_factory example Print instead of assert Remove bad quotes Remove bad quotes from all examples * fix change description * remove 'avoid-escape' from setup.cfg Co-authored-by: Samuel Colvin <s@muelcolvin.com>
13 lines
327 B
Python
13 lines
327 B
Python
from datetime import datetime
|
|
from uuid import UUID, uuid4
|
|
from pydantic import BaseModel, Field
|
|
|
|
class Model(BaseModel):
|
|
uid: UUID = Field(default_factory=uuid4)
|
|
updated: datetime = Field(default_factory=datetime.utcnow)
|
|
|
|
m1 = Model()
|
|
m2 = Model()
|
|
print(f'{m1.uid} != {m2.uid}')
|
|
print(f'{m1.updated} != {m2.updated}')
|