Springfield
raw JSON → 0.9.1 verified Sat May 09 auth: no python
A backend agnostic data modeling entity library. Current version 0.9.1, release cadence is irregular. Designed for flexible data modeling with support for multiple backends.
pip install springfield Common errors
error ImportError: cannot import name 'Entity' from 'springfield.models' ↓
cause In version 0.9, Entity is exported from the top-level springfield module, not springfield.models.
fix
Change import to 'from springfield import Entity'.
error AttributeError: 'Entity' object has no attribute 'dict' ↓
cause The .dict() method may not exist if using older version <0.9.0 or if the model is not set up correctly.
fix
Ensure you are using springfield >=0.9.0 and that Person is defined with Field() for each attribute. Alternatively, use .to_dict().
Warnings
gotcha Using 'from springfield.models import Entity' leads to ImportError. Entity is at the top-level in version 0.9.x. ↓
fix Use 'from springfield import Entity'.
gotcha The library is still pre-1.0, expect API changes. Pin your dependency. ↓
fix Pin to 'springfield>=0.9,<1' in requirements.
Imports
- Entity wrong
from springfield.models import Entitycorrectfrom springfield import Entity - Field wrong
from springfield.fields import Fieldcorrectfrom springfield import Field
Quickstart
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())