Bundles are a small abstraction that allow Tastypie to pass data between resources. This allows us not to depend on passing request
to every single method (especially in places where this would be overkill). It also allows resources to work with data coming into the application paired together with an unsaved instance of the object in question. Finally, it aids in keeping Tastypie more thread-safe.
Think of it as package of user data & an object instance (either of which are optionally present).
All data within a bundle can be optional, especially depending on how it's being used. If you write custom code using Bundle
, make sure appropriate guards are in place.
Either a Python object or None
.
Usually a Django model, though it may/may not have been saved already.
Always a plain Python dictionary of data. If not provided, it will be empty.
Either the Django request
that's part of the issued request or an empty HttpRequest
if it wasn't provided.
Either another "parent" Python object or None
.
Useful when handling one-to-many relations. Used in conjunction with related_name
.
Either a Python string name of an attribute or None
.
Useful when handling one-to-many relations. Used in conjunction with related_obj
.