Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

CircleCI build status Code coverage

Views for Django apps, primarily for use in Webteam Django apps.

Installation

You can install this module directly with pip install canonicalwebteam.django_views, or alternatively, include canonicalwebteam.django_views in requirements.txt for your app.

TemplateFinder

TemplateFinder is an extension of TemplateView which attempts to load the corresponding templates directly from URLs, without the need to write a view for each URL.

It can load HTML templates directly, or parse Markdown files that contain a “wrapper_template” frontmatter key.

Usage

Here’s an example of how to make use of TemplateFinder in your Django app:

# urls.py
from django.conf.urls import url
from canonicalwebteam.django_views import TemplateFinder
# ...
urlpatterns += url(r"$^", TemplateFinder.as_view()),

Template matching

When the app parses a URL, it will look for templates in the following locations, in order:

  • /parent/location/ => templates/parent/location.html

  • /parent/location/ => templates/parent/location/index.html

  • /parent/location/ => templates/parent/location.md

  • /parent/location/ => templates/parent/location/index.md

Markdown parsing

If the TemplateFinder encounters a Markdown file (ending .md) it will look for the following keys in YAML frontmatter:

  • wrapper_template mandatory: (e.g.: wrapper_template: /includes/markdown-wrapper.html) A path to an HTML template within which to place the parsed markdown content. If the path doesn’t have a leading slash (e.g. “templates/template.html” or “../templates/template.html”), then TemplateFinder will search for the template relative to the location of the Markdown file in question. If the path

  • context optional: (e.g.: context: {title: "Welcome", description: "A welcome page"}) A dictionary of extra key / value pairs to pass through to the template context.

  • markdown_includes optional: (e.g.: markdown_includes: {nav: }) A mapping of key names to template paths pointing to Markdown files to include. Each template path will be parsed, the resulting HTML will be passed in the template context, under the relevant key.

Here’s an example Markdown file:

---
wrapper_template: "/includes/markdown-wrapper.html"
markdown_includes:
  nav: "includes/nav.md"
context:
  title: "Welcome"
  description: "A welcome page"
---

Welcome to my website.

## GitHub

I also have [a GitHub page](https://github.com/me).

Metadata

Release files for canonicalwebteam.django-views 1.4.0

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

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for canonicalwebteam.django-views 1.4.0
File Size Uploaded
canonicalwebteam.django_views-1.4.0.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for canonicalwebteam.django-views 1.4.0
File Interpreter ABI Platform
canonicalwebteam.django_views-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / canonicalwebteam.django_views-1.4.0.tar.gz

Download URL canonicalwebteam.django_views-1.4.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1153a639dbfd4d2e4b51ebc538906c63ab7c9d8b175a93178c869e1f6ee539d8
BLAKE2b-256 checksum
How to use checksums
1a416f672edbaca14ea2da1bc3a3d0e392c7cc5fd972964af88198f5460f075d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.6.8

Release files / canonicalwebteam.django_views-1.4.0-py3-none-any.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL canonicalwebteam.django_views-1.4.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30035be67c955d2b3ab2a03b61bbd308e0f3c0a09dce294ec3c83ba509c0e001
BLAKE2b-256 checksum
How to use checksums
69710439ccf2c54de268d7e86a0bc784654bec2bf933450e0d4b8e68ff9cdba9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.4

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

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