These models are used in the databases of content that get imported from Studio. Any fields added here (and not in are assumed to be locally calculated cached fields. If a field is intended to be imported from a content database generated by Studio, it should be added in

DEVELOPER WARNING regarding updates to these models

If you modify the schema here, it has implications for the content import pipeline because we will need to calculate these values during content import (as we they will not be present in the content databases distributed by Studio).

In the case where new fields are added that do not need to be added to an export schema the generate_schema command should be run like this:

kolibri manage generate_schema current

This will just regenerate the current schema for SQLAlchemy, so that we can use SQLAlchemy to calculate these fields if needed (this can frequently be more efficient than using the Django ORM for these calculations).

class kolibri.core.content.models.AssessmentMetaData(*args, **kwargs)[source]

A model to describe additional metadata that characterizes assessment behaviour in Kolibri. This model contains additional fields that are only revelant to content nodes that probe a user’s state of knowledge and allow them to practice to Mastery. ContentNodes with this metadata may also be able to be used within quizzes and exams.

  • id (UUIDField) – Id

  • contentnode_id (ForeignKey to ~) – Contentnode

  • assessment_item_ids (JSONField) – Assessment item ids

  • number_of_assessments (IntegerField) – Number of assessments

  • mastery_model (JSONField) – Mastery model

  • randomize (BooleanField) – Randomize

  • is_manipulable (BooleanField) – Is manipulable

exception DoesNotExist
exception MultipleObjectsReturned
class kolibri.core.content.models.ChannelMetadata(*args, **kwargs)[source]

Holds metadata about all existing content databases that exist locally.

  • id (UUIDField) – Id

  • name (CharField) – Name

  • description (CharField) – Description

  • tagline (CharField) – Tagline

  • author (CharField) – Author

  • version (IntegerField) – Version

  • thumbnail (TextField) – Thumbnail

  • last_updated (DateTimeTzField) – Last updated

  • min_schema_version (CharField) – Min schema version

  • root_id (ForeignKey to ~) – Root

  • published_size (BigIntegerField) – Published size

  • total_resource_count (IntegerField) – Total resource count

  • order (PositiveIntegerField) – Order

  • public (NullBooleanField) – Public

  • included_languages (ManyToManyField) – Languages

exception DoesNotExist
exception MultipleObjectsReturned
class kolibri.core.content.models.ChannelMetadataQueryset(model=None, query=None, using=None, hints=None)[source]
class kolibri.core.content.models.ContentNode(*args, **kwargs)[source]

The primary object type in a content database. Defines the properties that are shared across all content types.

It represents videos, exercises, audio, documents, and other ‘content items’ that exist as nodes in content channels.

  • id (UUIDField) – Id

  • parent_id (TreeForeignKey to ~) – Parent

  • license_name (CharField) – License name

  • license_description (TextField) – License description

  • title (CharField) – Title

  • coach_content (BooleanField) – Coach content

  • content_id (UUIDField) – Content id

  • channel_id (UUIDField) – Channel id

  • description (TextField) – Description

  • sort_order (FloatField) – Sort order

  • license_owner (CharField) – License owner

  • author (CharField) – Author

  • kind (CharField) – Kind

  • available (BooleanField) – Available

  • lang_id (ForeignKey to ~) – Lang

  • options (JSONField) – Options

  • num_coach_contents (IntegerField) – Num coach contents

  • on_device_resources (IntegerField) – On device resources

  • lft (PositiveIntegerField) – Lft

  • rght (PositiveIntegerField) – Rght

  • tree_id (PositiveIntegerField) – Tree id

  • level (PositiveIntegerField) – Level

  • has_prerequisite (ManyToManyField) – Has prerequisite

  • related (ManyToManyField) – Related

  • tags (ManyToManyField) – Tags

exception DoesNotExist
exception MultipleObjectsReturned

Retrieve a queryset of content_ids for non-topic content nodes that are descendants of this node.

class kolibri.core.content.models.ContentNodeManager[source]
build_tree_nodes(data, target=None, position='last-child')[source]

vendored from:

get_queryset(*args, **kwargs)[source]

Ensures that this manager always returns nodes in tree order.

class kolibri.core.content.models.ContentNodeQueryset(model=None, query=None, using=None, hints=None)[source]
class kolibri.core.content.models.ContentTag(id, tag_name)[source]
  • id (UUIDField) – Id

  • tag_name (CharField) – Tag name

exception DoesNotExist
exception MultipleObjectsReturned
class kolibri.core.content.models.File(*args, **kwargs)[source]

The second to bottom layer of the contentDB schema, defines the basic building brick for content. Things it can represent are, for example, mp4, avi, mov, html, css, jpeg, pdf, mp3…

  • id (UUIDField) – Id

  • local_file_id (ForeignKey to ~) – Local file

  • contentnode_id (ForeignKey to ~) – Contentnode

  • preset (CharField) – Preset

  • lang_id (ForeignKey to ~) – Lang

  • supplementary (BooleanField) – Supplementary

  • thumbnail (BooleanField) – Thumbnail

  • priority (IntegerField) – Priority

exception DoesNotExist
exception MultipleObjectsReturned

Return the preset.

class kolibri.core.content.models.Language(id, lang_code, lang_subcode, lang_name, lang_direction)[source]
  • id (CharField) – Id

  • lang_code (CharField) – Lang code

  • lang_subcode (CharField) – Lang subcode

  • lang_name (CharField) – Lang name

  • lang_direction (CharField) – Lang direction

exception DoesNotExist
exception MultipleObjectsReturned
class kolibri.core.content.models.LocalFile(*args, **kwargs)[source]

The bottom layer of the contentDB schema, defines the local state of files on the device storage.

  • id (CharField) – Id

  • extension (CharField) – Extension

  • available (BooleanField) – Available

  • file_size (IntegerField) – File size

exception DoesNotExist
exception MultipleObjectsReturned

Delete the stored file from disk.


Return a url for the client side to retrieve the content file. The same url will also be exposed by the file serializer.

class kolibri.core.content.models.LocalFileQueryset(model=None, query=None, using=None, hints=None)[source]