openedx.core.djangoapps.xmodule_django package#

Submodules#

openedx.core.djangoapps.xmodule_django.models module#

Useful django models for implementing XBlock infrastructure in django.

class openedx.core.djangoapps.xmodule_django.models.BlockTypeKeyField(*args, **kwargs)#

Bases: BlockTypeKeyField

A django Field that stores a BlockTypeKey object as a string.

class openedx.core.djangoapps.xmodule_django.models.CourseKeyField(*args, **kwargs)#

Bases: CourseKeyField

A django Field that stores a CourseKey object as a string.

class openedx.core.djangoapps.xmodule_django.models.NoneToEmptyManager(*args, **kwargs)#

Bases: Manager

A django.db.models.Manager that has a NoneToEmptyQuerySet as its QuerySet, initialized with a set of specified field_names.

get_queryset()#

Returns the result of NoneToEmptyQuerySet instead of a regular QuerySet.

class openedx.core.djangoapps.xmodule_django.models.NoneToEmptyQuerySet(model=None, query=None, using=None, hints=None)#

Bases: QuerySet

A django.db.query.QuerySet that replaces None values passed to filter and exclude with the corresponding Empty value for all fields with an Empty attribute.

This is to work around Django automatically converting exact queries for None into isnull queries before the field has a chance to convert them to queries for it’s own empty value.

class openedx.core.djangoapps.xmodule_django.models.OpaqueKeyField(*args, **kwargs)#

Bases: OpaqueKeyField

A django field for storing OpaqueKeys.

The baseclass will return the value from the database as a string, rather than an instance of an OpaqueKey, leaving the application to determine which key subtype to parse the string as.

Subclasses must specify a KEY_CLASS attribute, in which case the field will use from_string() to parse the key string, and will return an instance of KEY_CLASS.

class openedx.core.djangoapps.xmodule_django.models.UsageKeyField(*args, **kwargs)#

Bases: UsageKeyField

A django Field that stores a UsageKey object as a string.

class openedx.core.djangoapps.xmodule_django.models.UsageKeyWithRunField(*args, **kwargs)#

Bases: UsageKeyField

Subclass of UsageKeyField that automatically fills in missing run values, for old Mongo courses.

to_python(value)#

Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.

Module contents#