Metadata packages

Sometimes you need to be able to apply entire collections of metadata to an item at a single time, or be able to link some metadata into one unit that you can update across a large amount of items of different types.

One example of where this might be useful is branding. If you have a certain brand that you want to apply to, say, a range of podcasts, you could manually set those podcasts up to have a consistent set of images, stock titles and descriptions, and so on. This is quite tedious and any changes made later won’t automatically propagate to existing podcasts.

This is where metadata packages come in. Packages are metadata subject items that live in the metadata.models.package.Package model, which can be attached in a many-to-many relationship to your models using the metadata.models.package.PackageEntry attachable. (See the django-lass-utils documentation for information about how to use attachables.)

Using as a fallback for metadata subjects

The default hooks set can automatically try getting metadata from a metadata package if no item-specific metadata exists. Creating a method packages on the subject class that returns the reverse set of a package entry attachable will enable this. See the unit tests for an example.

Querying a package for metadata

metadata.models.package.Package implements metadata.mixins.MetadataSubjectMixin, so the standard interface for retrieving metadata works on them.

Project Versions

Table Of Contents

Previous topic

Usage

Next topic

Hooks

This Page