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.1.0.tar.gz (22.5 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.1.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for e3_django_learning_materials-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8975ba8e77f7586b3572c945677811c3200b6bf0cdb03ab8f2e8f61eb2ecb472
MD5 68c5dc707f976d2e68f23a1200c8cf53
BLAKE2b-256 f2740a829107313d890b08b4cd98fa6c5db99ad37fb5d34d3d9c2db86463a157

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for e3_django_learning_materials-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 446efef2b0ec92d1abaabd560dfac097f81dd663c6960ec1048ed7f49d45d16b
MD5 ab20e8f84f4c4127ed3fb84daff04cab
BLAKE2b-256 0de853aa398c61de2d0e78e7294f06a25cbe0c63f53c042e3b5ff498c6de7552

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