Skip to main content

DjangoCMS Render Context

The plugin for the Django CMS content management system. The plugin displays the context in the template. The context can be specified directly in JSON format. Or the context can be used as a media file. Or the context can be loaded from a URL. The template can be entered directly or selected from a list defined in the settings in the DJANGOCMS_RENDER_CONTEXT_TEMPLATES constant.

Supported source data formats (mimetype):

  • csv (text/csv)
  • json (application/json)
  • yaml (application/yaml)
  • xml (application/xml)
  • ods (application/vnd.oasis.opendocument.spreadsheet)

Install

Install the package from pypi.org.

pip install djangocms-render-context

Add into INSTALLED_APPS in your site settings.py:

INSTALLED_APPS = [
    ...
    "easy_thumbnails",
    "filer",
    "djangocms_render_context",
]

Optional urls

The following urls are not required. JavaScriptCatalog makes translations available for javascript. rcdata/ then detail from the list in context.

Add into site urls.py:

from django.conf.urls.i18n import i18n_patterns
from django.views.i18n import JavaScriptCatalog
from django.urls import path, register_converter
from django.urls.converters import StringConverter


class PackagesConverter(StringConverter):
    """JavaScriptCatalog packages converter."""
    # Same as SlugConverter, but with extra '+', that is used in JavaScriptCatalog as a sepearator in list of packages.
    regex = "[-a-zA-Z0-9_+]+"


register_converter(PackagesConverter, "pkg")

urlpatterns = [
    ...
] + i18n_patterns(
    path('jsi18n/<pkg:packages>/', JavaScriptCatalog.as_view(), name='jsi18n'),
    path('rcdata/', include(('djangocms_render_context.urls', 'djangocms_render_context'))),
)

The path name jsi18n can be redefined with the DJANGOCMS_RENDER_CONTEXT_JSI18N constant.

Extra settings

This value can be defined in settings.

  • DJANGOCMS_RENDER_CONTEXT_TEMPLATES - List of templates that the plugin can use.
  • DJANGOCMS_RENDER_CONTEXT_DETAIL_TEMPLATES - List of templates that the detail can use.

For example:

DJANGOCMS_RENDER_CONTEXT_TEMPLATES = (
    ("", ""),
    ("plugin.html", "Plugin"),
    ("schedule.html", "Schedule"),
)
DJANGOCMS_RENDER_CONTEXT_DETAIL_TEMPLATES = (
    ("", ""),
    ("detail.html", "Plugin detail"),
)
  • DJANGOCMS_RENDER_CONTEXT_PROCESSORS - List of functions that can work with plugin context.
  • DJANGOCMS_RENDER_CONTEXT_DETAIL_PROCESSORS - List of functions that can work with detail context.

For example:

DJANGOCMS_RENDER_CONTEXT_PROCESSORS = (
    ("", ""),
    ("mysite.utils.process_plugin", "Process plugin"),
)
DJANGOCMS_RENDER_CONTEXT_DETAIL_PROCESSORS = (
    ("", ""),
    ("mysite.utils.process_plugin_detail", "Process plugin detail"),
)

The function in mysite/utils.py:

from django.template.context import RequestContext


def process_plugin(instance: RenderContext, context: dict) -> dict:
    """Process plugin context."""
    context["data"]["extra"] = "content"
    return context


def process_plugin_detail(instance: RenderContext, context: RequestContext) -> RequestContext:
    """Process plugin context."""
    context["detail"]["extra"] = "content"
    return context

License

BSD-3-Clause

Metadata

Release files for djangocms-render-context 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangocms-render-context 1.5.0
File Size Uploaded
djangocms_render_context-1.5.0.tar.gz 366.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangocms-render-context 1.5.0
File Interpreter ABI Platform
djangocms_render_context-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 749.3 kB

Release files / djangocms_render_context-1.5.0.tar.gz

Download URL djangocms_render_context-1.5.0.tar.gz
Size 366.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a3475e28d70e3b2947a5433a6806e84cdf8865c1132b76eba866ce37d696f9d2
BLAKE2b-256 checksum
How to use checksums
e1c156de72c4fe58a1d0a8a927e6e0ea8baa4447cf3b4a60d2c87f661c6ec988
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / djangocms_render_context-1.5.0-py3-none-any.whl

Download URL djangocms_render_context-1.5.0-py3-none-any.whl
Size 383.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7c9d327dc33c043e86a955ab36b19bb586d3eeb8c3afd5bf18994949b0a1ebb
BLAKE2b-256 checksum
How to use checksums
4c6558c111b049ccbb2aca9592e3ff65a975b2ca467c613c4cff93c307916834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.0

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page