API reference¶
The public API of the djiiif package. Everything below is generated from the
source docstrings, so it always matches the installed version.
Fields and accessor¶
- class IIIFField(verbose_name=None, name=None, width_field=None, height_field=None, **kwargs)[source]¶
An
ImageFieldwhose field files carry IIIF URLs via.iiif.- attr_class¶
alias of
IIIFFieldFile
- class IIIFFieldFile(instance, field, name)[source]¶
An
ImageFieldFilethat exposes an.iiifaccessor.- property iiif: IIIFObject¶
Return a freshly built
IIIFObjectfor this field file.
- class IIIFObject(parent)[source]¶
The
.iiifaccessor for a field file: profile URLs and documents.Constructed fresh on each
IIIFFieldFile.iiifaccess. For a populated field it eagerly sets one attribute persettings.IIIF_PROFILESname (the assembled Image API URL) plusinfo(the externalinfo.jsonURL) andidentifier(the plain{host}/{identifier}base URI). For an empty or unset field every URL attribute is the empty string.The generated documents —
info_documentandmanifest— are lazycached_propertyvalues because, unlike the URL attributes, they read the image’s pixel dimensions from storage. Constructing anIIIFObjecttherefore never touches the file.- as_dict(*, include_meta=False)[source]¶
Return the profile URLs as a plain
dict, keyed by profile name.Handy for JSON APIs (see
djiiif.serializers) and for iterating profiles in a template. For an empty/unset field every value is"".
- property info_document: dict | None¶
The IIIF Image API
info.jsondocument (not its URL).Distinct from
info, which returns the URL of an externalinfo.jsonserved by an image server. This builds the document here from the image’s ownwidth/heightand theidentifierbase URI, so a view can serve a minimalinfo.jsonwithout a separate image server (e.g.JsonResponse(field.iiif.info_document)).Accessing this reads the image from storage; the eager URL attributes never do. Shape is controlled by
settings.IIIF_IMAGE_API_VERSION(default3) andsettings.IIIF_COMPLIANCE_LEVEL(default"level2"). Whensettings.IIIF_AUTHresolves to a probe service for this image, its Authorization Flow 2.0serviceblock is included; whensettings.IIIF_INFOresolves to extras for this image (seeresolve_info()), those declarative properties (sizes,tiles, limits,rights, …) are emitted too.- Returns:
The
info.jsondocument, orNonefor an empty/unset field.
- property manifest: dict | None¶
A minimal single-image IIIF Presentation API 3.0 Manifest.
Wraps this image in a one-canvas manifest suitable for Mirador or OpenSeadragon. The label defaults to the file’s base name. Like
info_document, accessing this reads the image dimensions from storage. Whensettings.IIIF_AUTHresolves to a probe service for this image, its Authorization Flow 2.0serviceblock is attached to the image body. Whensettings.IIIF_MANIFEST_DESCRIPTORSresolves to a descriptor bag for this image (seeresolve_manifest_descriptors()), its descriptive properties (metadata,rights, …) are emitted at the manifest top level. Whensettings.IIIF_NAVPLACEresolves to a geometry for this image (seedjiiif.geo.resolve_navplace()), itsnavPlaceFeatureCollection is emitted (with the navPlace@context).- Returns:
The manifest document, or
Nonefor an empty/unset field.
- content_state(*, xywh=None, encoded=True)[source]¶
Build a IIIF Content State for a shareable deep link to this image.
Targets this image’s own Canvas (with a
partOfback to its Manifest), deriving both URIs the same waymanifestdoes — so the state opens the exact image the manifest describes. Passxywhto open zoomed to a region. Unlikemanifest, this reads nothing from storage.- Parameters:
- Returns:
The encoded string (
""for an empty/unset field), or the rawdict(Nonefor an empty/unset field) whenencodedis false.- Return type:
Profiles¶
- class Profile(host, region='full', size='max', rotation='0', quality='default', format='jpg', mirror=False, upscale=False)[source]¶
A typed, IIIF Image API 3.0-aware image profile.
A structured alternative to the raw
dictprofile shape, with 3.0-friendly defaults (size="max") and helpers for the two 3.0 features that are easy to get wrong as hand-written strings: mirroring (!rotation prefix) and upscaling (^size prefix). Existingdictand callable profiles keep working unchanged; this is purely an additive, opt-in convenience.- Parameters:
- size¶
IIIF size parameter (
"max","w,","w,h"…). Ifupscaleis set and this does not already start with^, a^prefix is added when the spec is built.- Type:
- rotation¶
IIIF rotation in degrees as a string. If
mirroris set and this does not already start with!, a!prefix is added.- Type:
- resolve_profile(profile, parent)[source]¶
Normalize any supported profile shape into a plain spec
dict.Accepts the three configured shapes — a
Profile, a callable receivingparentand returning aProfileordict, or a plaindict— and returns a uniformdictfor URL assembly.- Parameters:
profile – The value from
settings.IIIF_PROFILESfor one profile name.parent – The
IIIFFieldFilepassed to callable profiles.
- Returns:
A resolved spec dict containing the keys in
PROFILE_KEYS.- Raises:
ImproperlyConfigured – If
profile(or a callable’s return value) is not aProfile, callable, ordict.- Return type:
- image_url(spec, identifier)[source]¶
Assemble a full IIIF Image API request URL from a resolved spec.
- encode_identifier(name)[source]¶
Percent-encode a field-file name into a IIIF identifier segment.
The IIIF Image API treats the identifier as a single path segment, so every character in the reserved to-encode set (
/ ? # [ ] @ %and friends) must be percent-encoded — not just/.quote(safe="")encodes everything outside the unreserved set, which is a superset of the required behavior and keeps ordinary filenames (foo.jpg) untouched while correctly encodinga/b.jpg→a%2Fb.jpgand names containing spaces,?,#, etc.
Image & Presentation documents¶
- build_info_document(id_url, width, height, *, version=None, level=None, auth=None, extras=None)[source]¶
Build a spec-conformant IIIF Image API
info.jsondocument.- Parameters:
id_url (str) – The image service base URI (
{host}/{identifier}).width (int) – Image width in pixels.
height (int) – Image height in pixels.
version (int | None) – Image API version (
2or3); defaults tosettings.IIIF_IMAGE_API_VERSION(3).level (str | None) – Advertised compliance level; defaults to
settings.IIIF_COMPLIANCE_LEVEL("level2").auth (dict | None) – An optional resolved Authorization Flow 2.0 probe-service
dict(seeresolve_auth()). When present it is added to the document’sservicearray; only valid at version 3.extras (dict | None) – An optional normalized extras dict (see
resolve_info()) of declarative properties —sizes,tiles, size limits,rights, preferred/extra capabilities. v2 accepts onlysizes/tiles.
- Returns:
The
info.jsondocument as a dict, ready forJsonResponse.- Raises:
ImproperlyConfigured – If
versionis unknown,authis set while not on version 3, or anextrasv3-only key is present at version 2.- Return type:
- build_manifest(id_url, width, height, *, label, version=None, level=None, auth=None, nav_place=None, **descriptors)[source]¶
Build a minimal single-image IIIF Presentation API 3.0 Manifest.
A thin wrapper over
build_multi_manifest()for the common one-image case: the manifest wraps one image on one canvas so it opens directly in viewers like Mirador or OpenSeadragon. With nodescriptorsits output is identical to the historical single-image manifest.- Parameters:
id_url (str) – The image service base URI (
{host}/{identifier}), reused as the image serviceidand as the stem for the synthetic URIs.width (int) – Image width in pixels.
height (int) – Image height in pixels.
label – Human-readable label for the manifest (coerced via
_language_map()).version (int | None) – Image API version of the embedded image service (
2or3); defaults tosettings.IIIF_IMAGE_API_VERSION(3).level (str | None) – Advertised compliance level; defaults to
settings.IIIF_COMPLIANCE_LEVEL("level2").auth (dict | None) – An optional resolved Authorization Flow 2.0 probe-service
dict(seeresolve_auth()). When present it is added to the access-controlled image body’sservicearray; only valid at version 3.nav_place (dict | None) – An optional GeoJSON
FeatureCollection(seedjiiif.geo.resolve_navplace()) emitted as the manifest’snavPlace; switches@contextto the navPlace array.**descriptors – Optional descriptive properties (keys in
DESCRIPTOR_KEYS) emitted at the manifest top level.
- Returns:
The manifest as a dict, ready for
JsonResponse.- Raises:
ImproperlyConfigured – If
versionis unknown,authis set while not on version 3, or a descriptor key is unknown.- Return type:
- build_multi_manifest(id_url, images, *, label, version=None, level=None, auth=None, nav_place=None, **descriptors)[source]¶
Build a multi-canvas IIIF Presentation API 3.0 Manifest.
Presents several images as one manifest — recto/verso, a paged object, detail shots — by repeating the single-canvas structure with per-canvas indexed
idURIs. The document is always Presentation 3.0; each embedded image service reflects the Image APIversion.- Parameters:
id_url (str) – The manifest’s image service base URI (
{host}/{identifier}), the stem for the synthetic manifest/canvas URIs.images – A sequence of per-canvas specs —
(service_id_url, width, height)tuples, or dicts withid/width/heightand an optionallabel(see_normalize_image_spec()).label – Manifest label (coerced via
_language_map()).version (int | None) – Image API version of the embedded image services (
2or3); defaults tosettings.IIIF_IMAGE_API_VERSION(3).level (str | None) – Advertised compliance level; defaults to
settings.IIIF_COMPLIANCE_LEVEL("level2").auth (dict | None) – An optional resolved Authorization Flow 2.0 probe-service
dictapplied to every image body; only valid at version 3.nav_place (dict | None) – An optional GeoJSON
FeatureCollectiondict (seedjiiif.geo.resolve_navplace()) emitted as the manifest’snavPlace. When present,@contextbecomes the two-element navPlace array and Features gain synthesized ids.**descriptors – Optional descriptive properties (keys in
DESCRIPTOR_KEYS) emitted at the manifest top level.
- Returns:
The manifest as a dict, ready for
JsonResponse.- Raises:
ImproperlyConfigured – If
versionis unknown,authis set while not on version 3, or a descriptor key is unknown.- Return type:
- build_collection(id_url, items, *, label, **descriptors)[source]¶
Build a IIIF Presentation API 3.0 Collection of manifest references.
A Collection groups manifests for browsing — the natural rendering of a Django queryset (“all photos in this album”). It embeds only references to each manifest (id/type/label/thumbnail), never the manifests themselves, so even a large collection stays a small response.
- Parameters:
id_url (str) – The Collection’s own
idURI.items – A sequence of member entries —
(manifest_url, label)or(manifest_url, label, thumbnail)tuples, or already-formed member dicts (passed through).labelis coerced via_language_map();thumbnailvia_thumbnail().label – Collection label (coerced via
_language_map()).**descriptors – Optional descriptive properties (keys in
DESCRIPTOR_KEYS) emitted at the collection top level.
- Returns:
The Collection as a dict, ready for
JsonResponse.- Raises:
ImproperlyConfigured – If a descriptor key is unknown.
- Return type:
- class InfoExtras(sizes=None, tiles=None, max_width=None, max_height=None, max_area=None, rights=None, preferred_formats=None, extra_qualities=None, extra_formats=None, extra_features=None)[source]¶
Typed, opt-in optional
info.jsonproperties (a dual-shape helper).A structured alternative to a raw
dictforIIIF_INFO(theProfile/ProbeServiceprecedent), with one field per optional Image API property. Every field defaults toNoneand is emitted only when set. djiiif does not verify these against the real image server — the operator declares what their server supports and djiiif advertises it.- Parameters:
- max_width / max_height / max_area
Server-enforced size limits.
- extra_qualities / extra_formats / extra_features
Capabilities beyond the compliance level (v3).
- resolve_info(parent)[source]¶
Resolve
settings.IIIF_INFOto a normalized extrasdictfor an image.Mirrors
resolve_auth(): the setting may be adict, anInfoExtras, a callable returning either (orNone), or unset.- Parameters:
parent – The value passed to a callable config. On model paths this is the
IIIFFieldFile; on view paths it is the decoded storage name (str) — both expose the identity a callable branches on. The documented callable signature is thereforeparent: IIIFFieldFile | str.- Returns:
A normalized extras dict (empty when unset or resolved to
None).- Raises:
ImproperlyConfigured – If the (resolved) value is not a
dict,InfoExtras, orNone, or carries an unknown/duplicate key.- Return type:
Content State¶
- build_content_state(manifest_id, *, canvas_id=None, xywh=None)[source]¶
Build a IIIF Content State API 1.0 annotation targeting a resource.
Produces the spec’s simplified target forms (Content State API 1.0 §3.2): with only
manifest_idthe state targets the Manifest; withcanvas_idit targets that Canvas and carries apartOfback to the Manifest;xywhappends an#xywh=media-fragment to the canvas id to select a region.- Parameters:
manifest_id (str) – The Manifest URI (e.g.
{host}/{identifier}/manifest).canvas_id (str | None) – The Canvas URI to target within the manifest; omit to target the whole Manifest.
xywh (str | tuple[int, int, int, int] | None) – An optional region as an
x,y,w,hstring or 4-tuple of ints. Ignored whencanvas_idisNone.
- Returns:
The content-state
dict, ready forencode_content_state().- Return type:
- encode_content_state(state)[source]¶
Encode a content state for use as an
iiif-contentquery parameter.Implements the IIIF Content State API 1.0 §6 encoding: serialize to JSON (when given a
dict), percent-encode the UTF-8 string exactly as JavaScript’sencodeURIComponentdoes, base64url-encode that, and strip the=padding. The percent-encoding step is part of the spec — the resulting string round-trips through any viewer’sdecodeURIComponent.- Parameters:
state (dict | str) – A content-state
dict(e.g. frombuild_content_state()) or a bare resource-URIstr(the spec’s trivial form).- Returns:
The URL-safe, unpadded encoded string.
- Return type:
- decode_content_state(encoded)[source]¶
Decode an
iiif-contentvalue back into a content state.The inverse of
encode_content_state(): restore the stripped base64url padding, base64url-decode, reverse the percent-encoding, andjson.loadsthe result. A payload that is not JSON (a bare resource-URI string) is returned verbatim.
Change Discovery¶
- class Activity(object_id, end_time, type='Update', object_type='Manifest')[source]¶
One IIIF Change Discovery activity over a IIIF resource.
The typed, opt-in shape for an
IIIF_ACTIVITY_SOURCEentry — a structured alternative to a plaindictwith the same keys and defaults, normalized byresolve_activity()(theProfile/ProbeServicedual-shape precedent).- end_time¶
The modification timestamp — an aware
datetime(serialized ISO 8601) or a preformed ISO 8601 string.- Type:
- type¶
The activity type —
"Update"(default) or"Create"(both level-1)."Delete"is level-2 and out of scope here.- Type:
- resolve_activity(entry)[source]¶
Normalize an
IIIF_ACTIVITY_SOURCEentry to a plain dict.Mirrors
resolve_profile(): an entry may be anActivityor a plaindict(withobject_id/end_timerequired andtype/object_typeoptional). Both normalize to a dict carrying every key with defaults applied.
- build_activity(object_id, end_time, *, activity_type='Update', object_type='Manifest')[source]¶
Build one ActivityStreams activity for an
orderedItemslist.- Parameters:
object_id (str) – The activity object’s URL (a manifest or collection).
end_time (datetime | str) – The modification timestamp — an aware
datetime(serialized via.isoformat()) or a preformed ISO 8601 string.activity_type (str) – The activity type (
"Update"/"Create").object_type (str) – The object’s IIIF type (
"Manifest"/"Collection").
- Returns:
The activity dict —
{"type", "object": {"id", "type"}, "endTime"}. No@context(activities are always embedded in a page).- Return type:
- build_ordered_collection(id_url, total, first_url, last_url)[source]¶
Build the Change Discovery
OrderedCollectionentry point.- Parameters:
- Returns:
The
OrderedCollectiondict, ready forJsonResponse.- Return type:
- build_collection_page(id_url, collection_url, activities, *, prev_url=None, next_url=None, start_index=None)[source]¶
Build one Change Discovery
OrderedCollectionPage.- Parameters:
id_url (str) – This page’s own URL.
collection_url (str) – URL of the owning
OrderedCollection(emitted aspartOf).activities (list[dict]) – The page’s activities (see
build_activity()), in ascendingendTimeorder.prev_url (str | None) – URL of the previous page; omitted on the first page.
next_url (str | None) – URL of the next page; omitted on the last page.
start_index (int | None) – 0-based index of this page’s first item within the whole stream; omitted when
None.
- Returns:
The
OrderedCollectionPagedict, ready forJsonResponse.- Return type:
Annotations and search¶
- class Annotation(text=None, motivation='supplementing', xywh=None, language=None, format='text/plain', id=None, canvas_id=None, exact=None, before=None, after=None)[source]¶
A W3C Web Annotation over a canvas — the shared annotation/search hit type.
One typed, opt-in shape for both the annotation-serving backend (
IIIF_ANNOTATIONS_BACKEND) and the search backend (IIIF_SEARCH_BACKEND): a search hit is an annotation plus snippet context. A plaindictwith the same keys works too, normalized byresolve_annotation()(theProfile/ProbeServicedual-shape precedent).- Parameters:
- text¶
The body value — a string wrapped as a
TextualBody, or a preformedbodydictfor a non-textual body.
- motivation¶
The annotation motivation;
"supplementing"(default, the transcription/OCR case),"commenting","tagging", …- Type:
- canvas_id¶
The target canvas URI — required for a search hit (which locates itself on a canvas); unused when serving an annotation page (the canvas is implied by the page URL).
- Type:
str | None
- resolve_annotation(entry)[source]¶
Normalize an annotation/search-hit entry to a plain dict.
Mirrors
resolve_profile(): an entry may be anAnnotationor a plaindict(any subset of the annotation keys; missing keys take their defaults). Both normalize to a dict carrying every key in_ANNOTATION_DEFAULTS.- Parameters:
entry – An
Annotationor adict.- Returns:
A dict with every annotation key populated.
- Raises:
ImproperlyConfigured – If
entryis neither anAnnotationnor adict.- Return type:
- build_annotation(page_url, index, canvas_id, item)[source]¶
Build one W3C Annotation targeting a canvas.
- Parameters:
page_url (str) – The owning AnnotationPage / search URL, the stem for a synthesized id.
index (int) – The 1-based item index (used for the synthesized id).
canvas_id (str | None) – The target canvas URI; when
Nonethe annotation’s owncanvas_idis used (the search-hit case).item – An
Annotationor annotationdict.
- Returns:
The Annotation dict —
{id, type, motivation, body, target}— wheretargetis the canvas URI, plus an#xywh=fragment when the item carries a region.- Return type:
- build_annotation_page(page_url, canvas_id, items)[source]¶
Build a W3C
AnnotationPageof annotations over one canvas.- Parameters:
page_url (str) – This page’s own URL (also the
id).canvas_id (str) – The canvas every annotation targets.
items – An iterable of
Annotationor annotationdictentries.
- Returns:
The
AnnotationPagedict, ready forJsonResponse. An emptyitemsyields a spec-valid empty page.- Return type:
- build_search_response(search_url, q, hits, *, ignored=())[source]¶
Build a Content Search 2.0 response (a search-flavored
AnnotationPage).Emits the matching annotations fully embedded in
itemsand a match block inannotations— anAnnotationPageofcontextualizingannotations, each targeting aSpecificResource(the matched annotation) via aTextQuoteSelector(prefix/exact/suffix).exactdefaults to the queryq.- Parameters:
search_url (str) – The search endpoint URL (the response
idappends?q=).q (str) – The query string.
hits – An iterable of
Annotationor hitdictentries; each supplies its owncanvas_id.ignored – Request parameter names the server did not act on, echoed in the
ignoredlist.
- Returns:
The search
AnnotationPagedict, ready forJsonResponse.- Return type:
Views and serializer¶
Drop-in views that serve IIIF documents for stored images.
Mounting djiiif.urls.urlpatterns turns a Django instance into a minimal
provider of two documents built from a stored image: an Image API info.json
(serve_info_json()) and a Presentation API manifest
(serve_manifest()). Each maps an identifier back to a stored image, reads
its dimensions, and returns the document built by the corresponding
djiiif builder. Neither serves derivative pixels — only the JSON
documents.
Two settings-driven views need no stored image: serve_collection() renders
a browsable Collection of manifest references, and serve_activity_collection()
/ serve_activity_page() render a paged IIIF Change Discovery activity stream
so aggregators can harvest what changed. serve_annotation_page() serves a
W3C AnnotationPage (transcriptions/OCR/commentary) and serve_search()
answers IIIF Content Search 2.0 queries; both draw from project-owned backend
callables, and serve_manifest() advertises them when configured.
- serve_info_json(request, identifier)[source]¶
Serve the
info.jsondocument for a stored image.The document’s
idis taken from the request URL (minus the/info.jsonsuffix) so it always matches the URL the document is served from, as the spec requires. Whensettings.IIIF_INFOis configured, its declarative extras are threaded in; a per-imageIIIF_INFOcallable receives the decoded storage name here (there is no field file on the view path — seedjiiif.resolve_info()).- Parameters:
request – The incoming
HttpRequest.identifier – The encoded identifier segment captured by the URLconf.
- Returns:
A JSON-LD
JsonResponsecarrying theinfo.jsondocument.- Raises:
Http404 – If the identifier does not resolve to a readable image.
- serve_manifest(request, identifier)[source]¶
Serve a single-image Presentation API manifest for a stored image.
The image service base URI is the request URL minus the
/manifestsuffix, matching the identifier theinfo.jsonview serves. The manifest label defaults to the file’s base name.When
IIIF_ANNOTATIONS_BACKENDis configured, the canvas gains anannotationsreference to this image’s AnnotationPage; when a search backend is available (a dedicatedIIIF_SEARCH_BACKENDor the annotations fallback), the manifest advertises aSearchService2. Both are view-only —IIIFObject.manifest(no request in scope) emits neither. WhenIIIF_NAVPLACEis configured its callable receives the decoded storage name here (no field file on the view path) and its geometry is emitted asnavPlace.- Parameters:
request – The incoming
HttpRequest.identifier – The encoded identifier segment captured by the URLconf.
- Returns:
A JSON-LD
JsonResponsecarrying the manifest document.- Raises:
Http404 – If the identifier does not resolve to a readable image.
- serve_collection(request)[source]¶
Serve a IIIF Collection of manifest references.
Driven by the
IIIF_COLLECTION_SOURCEsetting — a callable returning an iterable of member entries ((manifest_url, label[, thumbnail])tuples or preformed member dicts, perdjiiif.build_collection()) and, optionally, alabelfor the collection itself. When the setting is unset the endpoint does not exist, so it returns404.The collection’s
idis the request URL, so it always matches where it is served from. The response reads no image storage — it references manifests by URL only.- Parameters:
request – The incoming
HttpRequest.- Returns:
A JSON-LD
JsonResponsecarrying the Collection document.- Raises:
Http404 – If
IIIF_COLLECTION_SOURCEis unset.
- serve_activity_collection(request)[source]¶
Serve the Change Discovery
OrderedCollectionentry point.Driven by
IIIF_ACTIVITY_SOURCE(see_activity_paginator()). The collection’sidis the request URL;first/lastpoint at the page routes. Reads no image storage.- Parameters:
request – The incoming
HttpRequest.- Returns:
A JSON-LD
JsonResponsecarrying theOrderedCollection.- Raises:
Http404 – If
IIIF_ACTIVITY_SOURCEis unset.
- serve_activity_page(request, page)[source]¶
Serve one Change Discovery
OrderedCollectionPage.The page’s activities are the source entries for this slice, resolved via
djiiif.resolve_activity()and built withdjiiif.build_activity(), kept in the source’s ascending-endTimeorder (the source owns that contract; djiiif does not re-sort).prev/nextare emitted at the interior boundaries only.- Parameters:
request – The incoming
HttpRequest.page – The 1-based page number (captured by the
<int:page>route).
- Returns:
A JSON-LD
JsonResponsecarrying theOrderedCollectionPage.- Raises:
Http404 – If
IIIF_ACTIVITY_SOURCEis unset orpageis out of range.
- serve_annotation_page(request, identifier)[source]¶
Serve a W3C
AnnotationPagefor a stored image.Draws its annotations from the
IIIF_ANNOTATIONS_BACKENDcallable(identifier, request) -> iterableofAnnotation/dictentries. The annotations target{id_url}/canvas/1, matching the canvasserve_manifest()emits. Reads no image storage.- Parameters:
request – The incoming
HttpRequest.identifier – The encoded identifier segment captured by the URLconf.
- Returns:
A JSON-LD
JsonResponsecarrying theAnnotationPage.- Raises:
Http404 – If
IIIF_ANNOTATIONS_BACKENDis unset.
- serve_search(request, identifier)[source]¶
Answer a IIIF Content Search 2.0 query for a stored image.
Uses
IIIF_SEARCH_BACKEND(identifier, q, request) -> iterableof hits when configured; otherwise falls back to a case-insensitive substring match overIIIF_ANNOTATIONS_BACKEND(so serving annotations yields search for free). A missing or emptyqreturns a valid empty page — never the whole corpus. Unimplemented spec parameters (motivation/date/user) are echoed inignored. Reads no image storage.- Parameters:
request – The incoming
HttpRequest.identifier – The encoded identifier segment captured by the URLconf.
- Returns:
A JSON-LD
JsonResponsecarrying the searchAnnotationPage.- Raises:
Http404 – If neither a search nor an annotations backend is configured.
- class IIIFSerializerField(*args, **kwargs)[source]¶
A read-only DRF field that serializes an
IIIFFieldto its profile URLs.Declare it on a serializer with the model’s IIIF field as the source:
class AssetSerializer(serializers.ModelSerializer): original = IIIFSerializerField() class Meta: model = Asset fields = ["id", "original"]
The representation is
djiiif.IIIFObject.as_dict(), i.e. a{profile_name: url}mapping (withinfo/identifierincluded wheninclude_metais set).- Parameters:
include_meta (bool)
- include_meta¶
Passed through to
as_dictto include theinfoandidentifierURLs.