Data model#
The data model is a direct relational translation of the CSL JSON 1.0.2 specification.
Entity overview#
Item ──< ItemName >── Name
│
├──< ItemDate
│
└──< ItemIdentifier
Model |
CSL JSON equivalent |
Purpose |
|---|---|---|
Top-level item object |
Scalar metadata fields (title, abstract, volume, etc.) |
|
Name-variable object |
A person or organization (family, given, literal) |
|
Name-variable array entry |
Associates a |
|
Date-variable object |
A structured date or date range for a specific CSL date slot |
|
Top-level string identifier fields |
A typed identifier (DOI, ISBN, ISSN, URL, PMID, PMCID) |
Item — Bibliographic entry#
Table: literature_item | CSL JSON: top-level item object
The Item model stores all scalar CSL JSON fields — strings, numbers, and booleans — as
database columns. Name variables (author, editor, etc.) are stored separately in ItemName.
Date variables are stored in ItemDate. Identifiers are stored in ItemIdentifier.
Key fields#
Django field |
CSL JSON field |
Notes |
|---|---|---|
|
|
Required; application-level unique (not DB UNIQUE); used as CSL |
|
|
Required; one of the 45 known |
|
|
|
|
|
Journal, book series, etc. |
|
|
|
|
|
Number-like fields stored as strings per CSL JSON spec |
|
|
TextField |
|
|
JSONField — list of category strings |
|
|
JSONField — arbitrary extra fields |
Five CSL JSON variables are not stored: citation-label, citation-number,
first-reference-note-number, locator and year-suffix. A citation processor assigns them for
one citation in one document, so they describe no reference. An import drops them, and an export
never writes them (ADR 0035).
Every other scalar CSL JSON field is represented. See the full field listing in the API reference.
Citation key uniqueness#
citation_key is not declared with unique=True, and nothing in the package keeps keys
distinct, so two references may carry the same key. See
Why citation keys may repeat.
Name — Person or organization#
Table: literature_name | CSL JSON: name-variable object
A Name stores one person or organization. The same Name record can be linked to
many items in different roles.
Django field |
CSL JSON field |
Notes |
|---|---|---|
|
|
Family/surname |
|
|
Given/first name |
|
|
Full name as a single string (no family/given split) |
|
|
e.g. “van” in Dutch names |
|
|
|
|
|
e.g. “Jr.”, “III” |
|
|
Place suffix after comma |
|
|
Use western vs. eastern ordering |
|
|
Instruct processor to parse name string |
Note
A Name with only literal set (no family/given) represents an organization or
any contributor whose name cannot be split into structured parts. These are handled
correctly on both import and export.
ItemName — Contributor link#
Table: literature_itemname | CSL JSON: entry in a name-variable array
ItemName is the ordered through-model linking Item to Name. Contributor
ordering is preserved per (item, role) scope: the order field is numbered
independently within each role on an item, so reordering authors never disturbs
editors (see ADR-0005).
Django field |
CSL JSON concept |
Notes |
|---|---|---|
|
— |
FK → |
|
— |
FK → |
|
name-variable key |
One of 26 |
|
position in array |
Assigned per |
Constraint: UNIQUE(item, role, name) — each person can appear at most once per
role per item.
ItemDate — Bibliographic date#
Table: literature_itemdate | CSL JSON: date-variable object
ItemDate represents a single CSL date-variable slot on an item. Each item can have
at most one date per slot (enforced by UNIQUE(item, date_type)).
Django field |
CSL JSON field |
Notes |
|---|---|---|
|
— |
FK → |
|
key name (e.g. |
One of 6 |
|
|
Start date as |
|
|
End date for ranges; null for single dates |
|
|
Seasonal qualifier (e.g. |
|
|
Approximate date flag |
|
|
Free-text date fallback |
|
|
JSONField fallback when structured parsing is not possible |
Date precision#
begin and end are PartialDateField values from
django-partial-dates, stored as YYYY, YYYY-MM or
YYYY-MM-DD text. The precision is preserved:
CSL |
Stored precision |
|---|---|
|
Year only |
|
Year + month |
|
Full date |
ItemIdentifier — Typed identifier#
Table: literature_itemidentifier | CSL JSON: top-level string fields like DOI, ISBN
Each item can have at most one identifier of each type (enforced by UNIQUE(item, type)).
Django field |
Notes |
|---|---|
|
FK → |
|
Identifier type string; well-known values are |
|
The identifier string |
Known identifier types: DOI, ISBN, ISSN, PMID, PMCID, URL.
All well-known types are validated at the model layer, on save() as well as
through full_clean(), so a direct ItemIdentifier.objects.create(...) cannot
store a malformed value:
Type |
Validation rule |
|---|---|
|
Must match |
|
Valid ISBN-10 or ISBN-13 check digit |
|
Must match |
|
Absolute URL with |
|
Numeric string |
|
|
A rejected ISBN distinguishes two failures: a value of the right shape whose check digit
does not match raises invalid_isbn_checksum, and a value that does not have ISBN-10’s or
ISBN-13’s shape at all raises invalid_isbn. ISSN does the same: a value of the right shape
whose check digit does not satisfy the standard’s modulo-11 checksum raises
invalid_issn_checksum, and a value that does not match \d{4}-\d{3}[\dX] at all raises
invalid_issn.
Unknown identifier types are accepted without format validation (a warning is logged).
bulk_create() does not call save(), so it bypasses these checks. That is
Django’s behaviour for every model. Call full_clean() yourself when you build
identifiers in bulk.
CSL JSON item types#
All 45 CSL JSON 1.0.2 item types are enumerated in ItemType.
Four use underscores rather than hyphens as defined in the specification:
legal_case, motion_picture, musical_score, personal_communication.
CSL JSON name roles#
All 26 CSL name-variable roles are enumerated in NameRole:
author, chair, collection-editor, compiler, composer, container-author,
contributor, curator, director, editor, editorial-director, executive-producer,
guest, host, illustrator, interviewer, narrator, organizer, original-author,
performer, producer, recipient, reviewed-author, script-writer,
series-creator, translator.