edx-when

raw JSON →
4.0.0 verified Fri May 01 auth: no python

A Django app for managing content scheduling and due dates in Open edX courses. It provides models and APIs for content dates, user-specific overrides, and schedule computation. Current version 4.0.0 (released 2025-05-07). Release cadence: irregular, with major version bumps when dropping Python/Django support.

pip install edx-when
error ModuleNotFoundError: No module named 'edx_when'
cause Library not installed or missing from requirements.
fix
Run: pip install edx-when
error AttributeError: module 'edx_when' has no attribute 'api'
cause Incorrect import path. The api module is a submodule, not a top-level attribute.
fix
Use: from edx_when.api import get_schedule_for_user
error django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured.
cause Using edx-when outside Django without calling django.setup() first.
fix
Call django.setup() after configuring DJANGO_SETTINGS_MODULE.
breaking Version 4.0.0 drops support for Python 3.11. You must use Python 3.12+. Check your deployment.
fix Upgrade to Python 3.12+ or pin to edx-when<4.0.0.
breaking Version 3.0.0 drops support for Python 3.8 and adds Python 3.12 support. Existing Python 3.8 deployments will break.
fix Upgrade to Python 3.9+ or use edx-when<3.0.0.
gotcha The get_schedule_for_user function requires a User ID (integer) and CourseKey; passing a username or course string will raise an AttributeError.
fix Use user.id and course_key. Convert course strings with CourseKey.from_string().

Fetches the first 3 schedule entries for a given user and course. Requires Django settings configured.

import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'yourproject.settings')

import django
django.setup()

from django.contrib.auth import get_user_model
from opaque_keys.edx.keys import CourseKey
from edx_when.api import get_schedule_for_user

def demo():
    user = get_user_model().objects.first()
    course_key = CourseKey.from_string('course-v1:DemoX+Demo_2024')
    schedule = get_schedule_for_user(user.id, course_key)
    print(schedule[:3] if schedule else 'No schedule found')

demo()