Skip to main content

A bilingual learning materials CMS for Django — create, manage, and serve articles, videos, and PDFs with role-based targeting

Project description

e3-django-learning-materials

PyPI version License: MIT Python versions

A bilingual (French/English) learning materials CMS for Django. Create, organize, translate, publish, and serve articles, videos, and PDFs with role-based targeting.

Installation

pip install e3-django-learning-materials

Quick Start

1. Add to INSTALLED_APPS

# settings.py
INSTALLED_APPS = [
    ...
    "rest_framework",
    "e3_learning_materials",
]

2. Include URLs

# urls.py
from django.urls import include, path

urlpatterns = [
    ...
    path("learning-materials/", include("e3_learning_materials.urls")),
    path("api/learning-materials/", include("e3_learning_materials.api_urls")),
]

3. Run migrations

python manage.py migrate e3_learning_materials

4. Visit /learning-materials/

Start creating and managing learning materials.

Templates

The package ships with a built-in base template (e3_learning_materials/base.html) so it works out of the box — no need to provide your own base.html.

To use your project's base template instead, set BASE_TEMPLATE in your settings:

E3_LEARNING_MATERIALS = {
    'BASE_TEMPLATE': 'my_project/base.html',
}

The only requirement is that your base template defines these Django blocks:

  • {% block content %} — main content area (required)
  • {% block extracss %} — extra stylesheets (optional)
  • {% block javascript %} — extra scripts, must include {{ block.super }} for jQuery/DataTables (optional)

Configuration

All settings go in an E3_LEARNING_MATERIALS dict in your Django settings:

E3_LEARNING_MATERIALS = {
    # Template extended by all learning-materials templates.
    # Default: "e3_learning_materials/base.html"
    "BASE_TEMPLATE": "myapp/base.html",

    # Dotted path to a permission-check function.
    # The function receives the request and returns True/False.
    # Example: "myapp.utils.is_admin"
    # If None (default), any authenticated user can access.
    "PERMISSION_CALLBACK": "myapp.utils.is_admin",

    # Directory prefix for file uploads under MEDIA_ROOT.
    # Default: "learning_materials"
    "UPLOAD_PATH_PREFIX": "my_uploads",

    # URL namespace used by the package.
    # Default: "e3_learning_materials"
    "URL_NAMESPACE": "e3_learning_materials",
}

Features

Content Model

Field Type Description
title_fr / title_en CharField Bilingual titles
summary_fr / summary_en TextField Bilingual summaries
body_fr / body_en TextField Bilingual body content
category ChoiceField Getting Started, Filing a Grievance, Your Rights, Triage & Processing, Escalation, Reporting Duties, FAQ
content_type ChoiceField Article, Video, PDF
target_roles JSONField Citizen, Facilitator, Village Secretary
languages JSONField French, English
status ChoiceField Draft, Published, Archived
read_time CharField Estimated reading time
file FileField PDF, JPG, PNG, MP4 upload

Web UI URLs

URL View Name
/learning-materials/ List + KPIs home
/learning-materials/data/ AJAX DataTable data data
/learning-materials/create/ Create form create
/learning-materials/<pk>/ Redirect to update detail
/learning-materials/<pk>/update/ Update form update
/learning-materials/<pk>/delete/ Delete confirmation delete

Use with {% url 'e3_learning_materials:home' %} (or your configured URL_NAMESPACE).

REST API

Method URL Auth Description
GET /api/learning-materials/ None List published materials (filtered by audience)
GET /api/learning-materials/<id>/ Token Retrieve a single material

Audience filtering:

GET /api/learning-materials/?audience=facilitator
GET /api/learning-materials/?audience=citizen
GET /api/learning-materials/?audience=both

Admin Integration

The LearningMaterial model is registered with Django admin with list display, filtering by category/content_type/status, and search.

Permissions

By default, any authenticated user can access learning materials. Set PERMISSION_CALLBACK to restrict access:

# myapp/utils.py
def is_admin(request):
    return request.user.is_staff

The callback receives the request object and must return True (grant access) or False (return 403).

Requirements

  • Django >= 4.1
  • Django REST Framework >= 3.14
  • Python >= 3.10

Development

pip install -e ".[dev]"
pytest tests/ -v

Publishing

See PUBLISH.md for instructions on publishing to PyPI.

Changelog

See CHANGELOG.md for release history.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

e3_django_learning_materials-0.3.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

e3_django_learning_materials-0.3.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file e3_django_learning_materials-0.3.0.tar.gz.

File metadata

File hashes

Hashes for e3_django_learning_materials-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d52ad8167fc2f154a652534077ef226177a8d08092d8988e70a4cbe80120820f
MD5 e4f20e09f0d87c6ce69b9cd4b5c8c686
BLAKE2b-256 78a9a6393700c11725c39d9f69a7cb28cc9f7ebcc2d27bd33325c544da458da0

See more details on using hashes here.

File details

Details for the file e3_django_learning_materials-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for e3_django_learning_materials-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac03bb49e6096941d42a21d5e7abd0dd6718d5f63b7c20854779c0545257ae3c
MD5 37b9f65b02a02d7af89ce96dae1ef606
BLAKE2b-256 284b556e9fb80069b3a79522b594ddfb8a214b4fd0df6ad4e375dd39c90846fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page