Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Entity
✓ from springfield import Entity
✗ from springfield.models import Entity
Entity is available directly from the top-level package.
Field
✓ from springfield import Field
✗ from springfield.fields import Field
Field is also at the top-level.
Define an entity model with fields and instantiate it.
from springfield import Entity, Field
class Person(Entity):
name: str = Field()
age: int = Field(default=0)
person = Person(name='Alice', age=30)
print(person.dict())
Errors
Common errors & fixes
ImportError: cannot import name 'Entity' from 'springfield.models'
In version 0.9, Entity is exported from the top-level springfield module, not springfield.models.
fixChange import to 'from springfield import Entity'.
AttributeError: 'Entity' object has no attribute 'dict'
The .dict() method may not exist if using older version <0.9.0 or if the model is not set up correctly.
fixEnsure you are using springfield >=0.9.0 and that Person is defined with Field() for each attribute. Alternatively, use .to_dict().
Upgrade
Version history
0.9.1latest on PyPI · released Sep 15, 2020
Audit
Dependencies
pydanticoptionalspringfield often used with pydantic for data validation